Tadeas Kriz
06/08/2023, 6:28 PMfir-plugins.md
doc file and the fir-plugin-prototype
it seems like there's no support for running a visitor/transformer similar to IrGenerationExtension
. Is that a current limitation, or am I just missing something? I'd like to run a transformer visitor on FIR in any of the FIR phases. Is it supported and if not, will it be? Thanks!
Or maybe if it'll still be through extensions like it is now, will there be support for more predicates, so we're not limited to annotations? For example a predicate like "all classes implementing an interface" or "all sealed interfaces", or even "all functions returning a type".Javier
06/08/2023, 6:49 PMFirBodyResolveTransformer
if I remember correctlyJavier
06/08/2023, 6:49 PMabstract class FirTransformer<in D> : FirVisitor<FirElement, D>()
semoro
06/08/2023, 7:02 PMIrGenerationExtension
is still supported in K2, note that FIR is a Compiler Frontend of K2, while IR is a backend part
Take a look at Parcelize implementation, which supports both K1 and K2 compilers and uses IrGenerationExtension
https://github.com/JetBrains/kotlin/blob/5802bf85878029ce840d0897d29ad5c4829c10e6/[…]c/org/jetbrains/kotlin/parcelize/ParcelizeComponentRegistrar.ktsemoro
06/08/2023, 7:04 PMJavier [8:49 PM]
we were modifying function bodies withif I remember correctlyFirBodyResolveTransformer
Javier [8:49 PM]
> Have you checked all classes that implement
Note thatCopy codeabstract class FirTransformer<in D> : FirVisitor<FirElement, D>()
FirTransformer
and FirBodyResolveTransformer
is actually a core internal API of FIR, that is highly-likely to change without prior notice
Not sure how you can use it to change bodies, since its only usage is to resolve raw FIRTadeas Kriz
06/08/2023, 7:04 PMFirBodyResolveTransformer
. I'm looking to edit the FIR so that there's new declarations visible to the source code, so IrGenerationExtension
is too late for mesemoro
06/08/2023, 7:06 PMFirDeclarationGenerationExtension
Tadeas Kriz
06/08/2023, 7:06 PMsemoro
06/08/2023, 7:08 PMTadeas Kriz
06/08/2023, 7:09 PMTadeas Kriz
06/08/2023, 7:09 PMsemoro
06/08/2023, 7:10 PMTadeas Kriz
06/08/2023, 7:12 PMsemoro
06/08/2023, 7:15 PMtype that implements interface X
that is used to generate other classes, let's say typeSome
interface X {}
class My : MySome(), X {}
/* generated class MySome { ... } */
Here, in order to determine if X
is really that interface X
that we are looking for, we need to resolve the super-type list
In order to do so, we need to query FirDeclarationGenerationExtension
for a name MySome
, which, in turn, will call predicate matching to find classes that implement interface X
, and here we have a cycle