mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
To support const vals and proper initialization order for companions of annotations (since 1.3+) as well as interfaces #KT-16962 Fixed
20 lines
368 B
Kotlin
Vendored
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"
|
|
|