Files
kotlin-fork/compiler/testData/codegen/box/annotations/annotationsOnLateinitFields.kt
T
pyos 50ae360ff9 FIR2IR: fix the way annotations are moved to fields
1. When an annotation has multiple targets, the priority goes like this:
    constructor parameter (if applicable) -> property -> backing field.

 2. The argument to `kotlin.annotation.Target` is a vararg, so that
    should be handled as well.

 3. `AnnotationTarget.VALUE_PARAMETER` allows receivers, constructor
    parameters, and setter parameters, while `AnnotationTarget.FIELD` allows
    both backing fields and delegates.

Known issue: java.lang.annotation.Target is not remapped to the Kotlin
equivalent, so things are still broken for pure Java annotations.
2020-11-30 20:29:18 +03:00

16 lines
272 B
Kotlin
Vendored

// WITH_REFLECT
// TARGET_BACKEND: JVM
@Target(AnnotationTarget.FIELD)
annotation class Ann
class C {
@Ann
lateinit var x0: String
}
fun box(): String {
require(C::class.java.getDeclaredField("x0")?.getAnnotation(Ann::class.java) != null)
return "OK"
}