Files
kotlin-fork/compiler/testData/codegen/box/reflection/properties/jvmFieldInInterfaceCompanionWithAnnotation.kt
T
Mikhael Bogdanov 1d283d243e Support @JvmField on interface properties
#KT-15807 Fixed
2018-07-16 16:13:15 +02:00

22 lines
519 B
Kotlin
Vendored

// !LANGUAGE: +JvmFieldInInterface
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// 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
}