Files
kotlin-fork/compiler/testData/codegen/box/reflection/properties/jvmField/interfaceCompanionWithAnnotation.kt
T
2018-08-01 12:29:24 +02:00

23 lines
530 B
Kotlin
Vendored

// !LANGUAGE: +JvmFieldInInterface
// IGNORE_BACKEND: JVM_IR
// TARGET_BACKEND: JVM
// WITH_REFLECT
import kotlin.reflect.full.declaredMemberProperties
annotation class Ann(val value: String)
public class Bar(public val value: String)
interface Foo {
companion object {
@JvmField @Ann("O")
val FOO = Bar("K")
}
}
fun box(): String {
val field = Foo.Companion::class.declaredMemberProperties.single()
return (field.annotations.single() as Ann).value + (field.get(Foo.Companion) as Bar).value
}