Kotlin - IntelliJ cannot resolve the reference (from synthetic class)

309 Views Asked by At

I am using Kotlin and I have the kotlinc compiler plugin (using arrow-meta library) in place which changes the .class by adding for example new properties or new method etc during kotlin compilation time. for example, the original source Kotlin A.kt is like below

@MetaData
data class A (val x: String, val y: String)

after applying compiler plugin, the .class will be altered to (from source perspective), basically I will add implicitly MetaData into the primary constructor for all class so long as it is with annonation @MetaData in place, plus a new method fun getMetaData() generated

    data class A(val x: String, val y:String, val myMeta: MetaData) {
       fun getMetaData() {
         //some logic check
         return myMeta
       }
    }

now when it comes to use the new synthetic "class" manipulated as below, IntelliJ complains it cannot find resolve A (it has only the constructor with 2 parameters not 3) and cannot resolve the the synthetic method getMetaData() either.

val x = A("ba", "fo", MetaData(..))
val y = x.getMetaData()

can somebody shed some light on it?

I know lombok seems no problem with it after adding its @Getter annotation for example into Java source code, IntelliJ can recognize its getXXX method (which is generated by lombok). I don't know how to implement the same for my case for kotlin language. please include the detailed steps if possible.

0

There are 0 best solutions below