Hi! Is it possible to generate `IrClass` that is n...
# compiler
d
Hi! Is it possible to generate
IrClass
that is not associated with existing (source) code (in a parent-child relationship)? I want to use this class in multiple existing files on the IR level but: • When I leave parent empty - class is not compiled • When I associate it with existing code - IC errors occur while removing class parent declaration from the source code
t
Yes, it is possible. You can add it to one of the files in the IrModuleFragment. However, you won't be able to see it in the IDE or use it from other modules.
d
I know that it won't be visible and I don't need it. Adding it to the one of files in IrModuleFragment falls into second case - IC errors when file is removed.
I just want to share
IrClass
between multiple
IrFile
s.
So I kind of need it to be "independent" to avoid IC errors.
t
Theoretically it's possible if you add a FIR plugin that creates a top-level declaration. But that's buggy and won't compile in multiplatform IIRC.
Also, adding a fully independent class will result a lot of problems during incremental compilation.
d
Is generating new
IrFile
possible?
I tried FIR and because of the bugs it's not really an option at the moment. I hoped there is any other solution.
t
I have no experience with that (adding an IrFile). I tried to solve a similar problem for weeks, but then I just gave up and used a different structure built on existing declarations.
d
So it's seems that I have to stick to redundancy. I need this independent class to just optimize redundancy. Anyway, thank you for help!