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:
Alexander Udalov
2021-07-24 03:33:42 +02:00
parent 67128c022a
commit 0a6d010d1c
23 changed files with 448 additions and 3 deletions
@@ -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"
}