We’re seeing some strange behavior when testing K2...
# k2-adopters
z
We’re seeing some strange behavior when testing K2 and I’m curious if anything changed about how the JavaCompile task in multimodule source sets changed In short, we have an IR transformer that adds super interfaces to some source interfaces. There is some KAPT code gen that appears to recognize these correctly, as it generates (Java) implementations of these interfaces with expected overrides. However, it seems that this is not visible to the later JavaCompile task, which complains that the overrides override nothing. Do JavaCompile tasks no longer see the post-IR-transformed compiled class files from the kotlin compilation anymore (i.e. are they being fed some source-based representation instead) or should I be looking to make sure that our IR plugin is correctly running in the kotlin compilation task too?
CC @tapchicoma as this may be more of a build pipeline change
t
How do you do such IR transformation? Via Kotlin compiler plugin?
The relevant bit where it adds interfaces to the IrClass is the addContributedInterfaces() function there
Line 569
t
does it work with previous 2.0.0 Beta releases or it is never worked in 2.0?
z
It appears to work fine during stub gen because the processor (in this case Dagger) sees them and generates expected code based on it
Never worked
Just never looked more closely into it because there was so much other build issues up to this point that I wasn’t sure if it was something wrong on our end
But now I’ve resolved the other build issues and this is the last one :)
t
hmm, I think it is worth to create an issue with repro. Hard to say what could go wrong here as last stable release was quite a long time ago and a lot of changes happened in 2.0. Generally there were no specific changes how compiled output is passed to
JavaCompile
z
Ok. Let me confirm the interfaces are present in the compiled classes from the kotlin compilation first
👍 1
t
btw, JiC does it reproduce with Kapt/K2 or with kapt3 as well?
z
Kapt K2 doesn’t get this far unfortunately
K2 kapt issue blocking that is https://youtrack.jetbrains.com/issue/KT-66541. I accidentally forgot to follow up but left some notes last night. Have a public repro I’ll be able to link today on it
👍 1
Looks like it's missing from the compiled class in the kotlin compilation too. Let me try to breakpoint the plugin and make sure it's being hit. One interesting note is that I do see that the plugin has partially run, because it did add the
@Component
annotation. This is suggesting to me that the plugin did run but was not able to find contributed classes from the ModuleDescriptor, and thus didn't believe it had any interfaces to add. When you compare it to the stub generated (second screenshot), it's missing all the information that stub generation did correctly see
so I guess the next question is - did anything change about classpath visibility to KotlinCompile that is different to how classpath visibility is to the stub generation task?
t
nope, should be the same. Maybe something in the compiler has changed
z
hmm, ok. I should be able to put up a public repro for both of these today. Waiting for an anvil release today that is needed for these to build
ok it looks like merging is finding everything correctly, added supertypes are just not getting compiled to the resulting bytecode
filed https://youtrack.jetbrains.com/issue/KT-67490 with detailed info and repro steps. I also added repro steps to the KAPT issue
thank you color 1