50ae360ff9
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.
16 lines
272 B
Kotlin
Vendored
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"
|
|
}
|