Files
kotlin-fork/compiler/testData/codegen/box/reflection/annotations/localClassLiteral.kt
T
Alexander Udalov ba150ca370 Add JVM target bytecode version 19
Test data in `box/annotations/typeAnnotations` is changed because nested
classes in type annotations are rendered differently in JDK 19
(`Outer.Nested` instead of `Outer$Nested`).

 #KT-54116 Fixed
2022-09-22 21:56:10 +02:00

30 lines
893 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_REFLECT
package test
import kotlin.reflect.KClass
annotation class Anno(val k1: KClass<*>, val k2: KClass<*>, val k3: KClass<*>)
fun box(): String {
class L
@Anno(k1 = L::class, k2 = Array<L?>::class, k3 = Array<out Array<L>>::class)
class M
val fqName = "test.LocalClassLiteralKt\$box\$L"
// JDK 8 and earlier
val expected1 = "[@test.Anno(k1=class $fqName, k2=class [L$fqName;, k3=class [[L$fqName;)]"
// JDK 9..18
val expected2 = "[@test.Anno(k1=$fqName.class, k2=$fqName[].class, k3=$fqName[][].class)]"
// JDK 19 and later
val expected3 = "[@test.Anno(k1=<no canonical name>.class, k2=<no canonical name>.class, k3=<no canonical name>.class)]"
val actual = M::class.annotations.toString()
if (actual != expected1 && actual != expected2 && actual != expected3) return "Fail: $actual"
return "OK"
}