damian
06/07/2023, 4:21 PMCompilerPluginRegistrar
in Kotlin 1.8.10, I ran across a strange issue that I can't seem to reproduce in tests, and it only seems to happen in certain places in my codebase.
My plugin alters the base classes of some classes, but I found that some classes have multiple different instances of `IrClass`/`IrClassSymbol`/etc in memory - that is to say, there are multiple objects referring to the same underlying class. For example, the superclass of class A (which I arrive at from a visitor) should be the same as the superclass of class B (which I retrieve through referenceClass
), but these two are actually different objects (though poking around in the debugger does show that they're basically the same except for the source
parameter - one has NO_SOURCE
, and one actually has it).
This is causing problems because there are various checks and assertions elsewhere the compiler that check whether one class is a subclass of other, which have started failing (again, only when this happens, which is /sometimes/) because the underlying check for class hierarchy uses reference equality. In my case there are assertion failures in the synthetic accessor lowering (which seems to only be trying to generate synthetic accessors in the first place because it finds that a calling class is not a subclass of a member's declaring class, which is not true).
Is anyone else aware of such a problem? I had a really hard time searching for this in a way that doesn't bring up other unrelated problems.Youssef Shoaib [MOD]
06/07/2023, 4:23 PMdamian
06/07/2023, 4:25 PMshikasd
06/07/2023, 4:55 PMdmitriy.novozhilov
06/08/2023, 7:23 AMCompilerPluginRegistrar
CompilerPluginRegistrar
and ComponentRegistrar
are purely identical. The only difference between them is that the first one hides Project
from the plugin. Underneath they do purely the samedamian
06/08/2023, 6:39 PMCompilerPluginRegistrar
, but perhaps as Andrei mentioned this resulted in compiler plugins running in a different order? I am using KSP as well, and the difference in the two instances is between a class from KSP and one not from KSP, so maybe that's where it's coming from...dmitriy.novozhilov
06/09/2023, 7:45 AMdamian
06/09/2023, 4:58 PM