Files
kotlin/compiler/testData/codegen/box/annotations/constValInAnnotation.kt
Ting-Yuan Huang 75646f97a4 MoveCompanionObjectFields: copy constants into interfaces
Fields having const attribute in companion objects are observable in
Java and should be copied to outer interfaces.
2019-05-20 08:43:00 +02:00

20 lines
368 B
Kotlin
Vendored

// !LANGUAGE: +NestedClassesInAnnotations
// WITH_RUNTIME
// TARGET_BACKEND: JVM
// FILE: Foo.java
@Anno(Anno.CONST)
public class Foo {}
// FILE: Anno.kt
annotation class Anno(val value: Int) {
companion object {
const val CONST = 42
}
}
fun box(): String =
if ((Foo::class.java.annotations.single() as Anno).value == 42) "OK" else "Fail"