https://kotlinlang.org logo
#compiler
Title
# compiler
a

Ayla

10/20/2023, 4:09 AM
Hello, I'm learning compiler plugin from compose compiler source code, and I want to confirm if the knowledge points I have summarized are correct: 1.currently, we cannot directly change function signature for K/JS target , so we need to use decoys to achive the same purpose. 2.DeepCopyIrTreeWithSymbols is required for K/JS and K1, and not for K2. I'm not sure if these are correct, thanks much for any guidance.
j

jw

10/20/2023, 4:16 AM
So the decoys haven't been needed since Kotlin 1.7 but disabling them is a breaking change so it hasn't been done (yet). From what I remember it was about overload resolution and not changing the signature, but I wouldn't trust me to be accurate about that! I simply can't remember exactly and I'm not an authority on the subject.
thank you color 1
s

shikasd

10/20/2023, 5:34 AM
1) decoys were a workaround for a very specific issue of changing signatures across modules, and they are now obsolete, as JS also started using IR stubs to provide declarations from other modules 2) we have to deep copy the tree in all cases (see ComposeTypeRemapper), as function types can be encountered almost anywhere in the IR tree. Technically, it is very inefficient, as we spend a lot of time copying IR that is potentially unrelated to Compose, but we haven't found a better solution for now.
thank you color 1
You cannot modify many fields (e.g. param type?) in IR, and compose has to change it
a

Ayla

10/20/2023, 8:22 AM
Thanks
2 Views