cab53361f3
Add some more filters on private/synthetic stuff (which doesn't matter in practice) to make full and light analysis mode dumps as similar as possible, so that all existing tests will pass for JVM IR. Unmute some tests which were failing with the old JVM backend. Tests on repeatable annotations are muted because in full analysis, annotations are wrapped into the container (e.g. `@A(1) @A(2)` -> `@A$Container(A(1), A(2))`), but they are no in the light analysis mode. So there's always going to be a difference for these tests between full and light analysis, unless we're going to change behavior of kapt, which would be a kind of a breaking change. #KT-58497 Fixed
52 lines
1.4 KiB
Kotlin
Vendored
52 lines
1.4 KiB
Kotlin
Vendored
// !LANGUAGE: +RepeatableAnnotations
|
|
// TARGET_BACKEND: JVM_IR
|
|
// JVM_TARGET: 1.8
|
|
// FULL_JDK
|
|
// WITH_REFLECT
|
|
|
|
// In light analysis mode, repeated annotations are not wrapped into the container. This is by design, so that in kapt stubs repeated
|
|
// annotations will be visible unwrapped.
|
|
// IGNORE_LIGHT_ANALYSIS
|
|
|
|
import kotlin.annotation.AnnotationTarget.*
|
|
import kotlin.reflect.KAnnotatedElement
|
|
import kotlin.reflect.full.findAnnotation
|
|
import kotlin.reflect.full.findAnnotations
|
|
import kotlin.reflect.full.hasAnnotation
|
|
|
|
fun check(element: KAnnotatedElement) {
|
|
if (!element.hasAnnotation<A>()) throw AssertionError("Fail hasAnnotation $element")
|
|
|
|
val find = element.findAnnotation<A>()
|
|
if (find == null || find.value != "O") throw AssertionError("Fail findAnnotation $element: $find")
|
|
|
|
val all = element.annotations
|
|
val findAll = element.findAnnotations<A>()
|
|
if (all != findAll) throw AssertionError("Fail findAnnotations $element: $all != $findAll")
|
|
|
|
if (all.any { it !is A })
|
|
throw AssertionError("Fail 1 $element: $all")
|
|
if (all.fold("") { acc, it -> acc + (it as A).value } != "OK")
|
|
throw AssertionError("Fail 2 $element: $all")
|
|
}
|
|
|
|
@Repeatable
|
|
@Target(CLASS, FUNCTION, PROPERTY)
|
|
annotation class A(val value: String)
|
|
|
|
@A("O") @A("") @A("K")
|
|
fun f() {}
|
|
|
|
@A("O") @A("") @A("") @A("K")
|
|
var p = 1
|
|
|
|
@A("O") @A("K")
|
|
class Z
|
|
|
|
fun box(): String {
|
|
check(::f)
|
|
check(::p)
|
|
check(Z::class)
|
|
return "OK"
|
|
}
|