jcechace
03/12/2022, 6:24 PMclazz.primaryConstructor!!.call(param)
When this line is executed from Kotlin code the primary consructor is returned. In Java I get a null value.wrongwrong
03/12/2022, 7:03 PMprimaryConstructor
to be null
even in a Kotlin
class.
import kotlin.reflect.full.primaryConstructor
class C {
val v: Int
constructor(v: Short) { this.v = v.toInt() }
}
fun main() {
println(C::class.primaryConstructor) // -> null
}
The primaryConstructor
will never be null
for a data class
.jcechace
03/13/2022, 3:48 PM