Support new repeatable annotations in kotlin-reflect
- Unwrap Kotlin-repeatable annotations (with implicit container) - Introduce `KAnnotatedElement.findAnnotations` to find instances of repeated annotations #KT-12794
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
// !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.reflect.full.findAnnotation
|
||||
import kotlin.reflect.full.findAnnotations
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
|
||||
annotation class Yes(val value: String)
|
||||
@@ -19,5 +22,7 @@ fun box(): String {
|
||||
assertNull(Bar::class.findAnnotation<Yes>())
|
||||
assertNull(Bar::class.findAnnotation<No>())
|
||||
|
||||
assertEquals("OK", Foo::class.findAnnotations<Yes>().single().value)
|
||||
|
||||
return Foo::class.findAnnotation<Yes>()?.value ?: "Fail: no annotation"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user