Hello. I'm playing with compiler plugins for K/N. ...
# compiler
a
Hello. I'm playing with compiler plugins for K/N. For each class with an annotation, my plugin generates an empty private class, and also generates a method that returns a new instance of that class. But but my sample app's build fails when linking a release framework for iOS. Debug framework is linked fine.
Copy code
e: java.lang.Error: Invalid LLVM module
Verification errors:
    inlinable function call in a function with debug info must have a !dbg location
      call void @"kfun:kotlinx.cinterop#superInitCheck__at__kotlinx.cinterop.ObjCObjectBase(kotlinx.cinterop.ObjCObject?){}"(%struct.ObjHeader* %0, %struct.ObjHeader* %19)
1
Here is how I generate the code.
I noticed that it works fine if I remove the following line:
Copy code
superTypes = listOf(context.referenceClass(FqName("platform.darwin.NSObject"))!!.defaultType)
But I need my generated class to extend NSObject, because later I will need to implement a Foundation protocol, and a class must extend NSObject if it implements a protocol.
The issue seems already fixed on Kotlin 1.8.0-RC, but I'm using Kotlin 1.7.21 and somehow I managed to fix the issue with the following changes: 1. Wrapped every
irCall
and
irWhile
with
irBlock(startOffset = SYNTHETIC_OFFSET, endOffset = SYNTHETIC_OFFSET) { ... }
2. Added
startOffset = SYNTHETIC_OFFSET
and
endOffset = SYNTHETIC_OFFSET
to the generated class. Somehow this resolves the issue with linking a release framework.