Files
kotlin-fork/compiler/testData/codegen/box/reflection/properties/jvmField/interfaceCompanion.kt
T
2019-11-19 11:00:09 +03:00

25 lines
519 B
Kotlin
Vendored

// !LANGUAGE: +JvmFieldInInterface
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// WITH_REFLECT
import kotlin.reflect.KProperty1
import kotlin.reflect.full.memberProperties
import kotlin.reflect.full.companionObject
class Bar(val value: String)
interface Foo {
companion object {
@JvmField
val z = Bar("OK")
}
}
fun box(): String {
val field = Foo::class.companionObject!!.memberProperties.single() as KProperty1<Foo.Companion, Bar>
return field.get(Foo.Companion).value
}