I'm making a compiler plugin which adds a field fo...
# compiler
s
I'm making a compiler plugin which adds a field for annotated functions and modifies said functions. When the method is a class member, everything works fine, but when the function is top-level, compiling to JVM fails to add the field in the resulting class file. Dumping the IR result shows that the field does exist. I am adding the field in the following way:
Copy code
val parent = declaration.parent
if (parent is IrDeclarationContainer) {
    parent.addChild(memoizeMap)
} else error(parent.dump())
This is the error at runtime. Running
javap
against the classfile also shows the absence of the field
I figured it out - the field was being created with
isStatic
matching that of the function, but that is
false
in most top-level functions. I fixed it by setting the static option to either the function being static or top-level
k
Ah