139e1223ea
`IrGeneratedDeclarationsRegistrar` assumes that all generated functions are correct from a Kotlin point of view. But `writeSelf` method on JVM is a static method outside any object/companion object So to properly calculate containing class for this method we should generate a dispatch receiver parameter, register the method in metadata, and then remove the parameter (to make function static)
20 lines
592 B
Kotlin
Vendored
20 lines
592 B
Kotlin
Vendored
// TARGET_BACKEND: JVM_IR
|
|
// WITH_REFLECT
|
|
|
|
import kotlinx.serialization.Serializable
|
|
import kotlin.reflect.jvm.javaConstructor
|
|
import kotlin.reflect.jvm.kotlinFunction
|
|
|
|
@Serializable
|
|
data class Tuple2<out A1, out A2>(
|
|
val _1: A1,
|
|
val _2: A2,
|
|
)
|
|
|
|
fun box(): String {
|
|
val cls = Tuple2::class
|
|
val ctor = cls.constructors.single { it.parameters.size == 4 }
|
|
val kf = ctor.javaConstructor?.kotlinFunction
|
|
return if (kf.toString() == "fun `<init>`(kotlin.Int, A1?, A2?, kotlinx.serialization.internal.SerializationConstructorMarker?): Tuple2<A1, A2>") "OK" else "Fail: $kf"
|
|
}
|