6be9101675
Otherwise a local class in a field initializer or anonymous init block is copied into each constructor of the containing class (because InitializersLowering calls deepCopy). Since the code structure no longer resembles the original source code here, record a custom EnclosingMethod mapping before moving such classes, and use it in codegen.
28 lines
522 B
Kotlin
Vendored
28 lines
522 B
Kotlin
Vendored
// TARGET_BACKEND: JVM
|
|
// FILE: A.kt
|
|
|
|
class A {
|
|
val o = object {
|
|
@JvmName("jvmGetO")
|
|
fun getO(): String = "O"
|
|
}
|
|
|
|
val k = object {
|
|
@get:JvmName("jvmGetK")
|
|
val k: String = "K"
|
|
}
|
|
}
|
|
|
|
// FILE: B.kt
|
|
|
|
import kotlin.reflect.full.*
|
|
|
|
fun box(): String {
|
|
val a = A()
|
|
val obj1 = a.o
|
|
val o = obj1::class.declaredMemberFunctions.single().call(obj1) as String
|
|
val obj2 = a.k
|
|
val k = obj2::class.declaredMemberProperties.single().call(obj2) as String
|
|
return o + k
|
|
}
|