I really wonder how things are working. I have a m...
# compose
e
I really wonder how things are working. I have a module that has compose library dependency but it was forgotten to enable plugin and set feature flag for AGP. Everything compiled but runtime was failing because module function was not updated to add compose related parameters. So I wonder how consumer of this function compiled without error, does it mean that compose compiler plugin modifies bytecode after?
e
it doesn't modify the bytecode after, it does completely change what bytecode is generated though
simplified,
Copy code
@Composable foo()
@Composable bar() { foo() }
the frontend sees that
@Composdable foo(): Unit
can call
@Composable bar(): Unit
then the codegen produces something equivalent to
Copy code
fun foo(composer: Composer, changed: Int) { bar(composer, ...) }
due to the Compose compiler plugin modifying how
@Composable
functions work
e
Then I'm not sure how kotlin compiler works. The consumer module compilation should see that bytecode doesn't have compose added params.
e
frontend isn't looking at the other module's bytecode to see that the declaration has or hasn't been processed by the compiler plugin and backend doesn't check. it just emits a call to the expected function signature
e
I'm not sure about that. Since why would I have a compile error if the library doesn't have such a function. And it will happen in IDE or if I compile from command line
e
you have a compile error when the frontend can'tresolve to something that doesn't exist. but, the model that it uses is one that contains
@Composable fun bar()
based on the Kotlin metadata which does exist, not based off of the presence or absence of
bar:(Landroidx/compose/runtime/Composer;I)V
in the bytecode
IDE or command line, same thing
e
Also not clear, because I remember compile time error when parameter not found or parameter type changed