I need to create some annotations in IR (using `Ir...
# compiler
a
I need to create some annotations in IR (using
IrConstructorCall
). Some of the annotations have arguments of type
Array<KClass<*>>
and
KClass<*>
. How does one create these expressions in IR? I see
IrClassReference
but not sure if that's relevant or how to create it
p
Code from my factory implementation:
Copy code
fun createClassRefExpr(
        klass: IrClass
    ): IrExpression {
        val classType = klass.defaultType
        return IrClassReferenceImpl(
            startOffset = this.startOffset, 
            endOffset = this.endOffset,
            type = this.builtIns.kClassClass.typeWith(classType),
            symbol = klass.symbol,
            classType = classType
        )
    }
To better understand how IR is represented, you can debug your compiler plugin code. See this message and message next to it: https://kotlinlang.slack.com/archives/C7L3JB43G/p1725626069009579?thread_ts=1725623682.461049&amp;cid=C7L3JB43G
a
Cool, thank you! Directly instantiating these
Impl
classes feels dirty but it seems that's just how one does it