Files
kotlin-fork/compiler/testData/codegen/box/annotations/singleAssignmentToVarargInAnnotation.kt
T
Ilya Chernikov 78ca733c38 FIR JS: add K2 variants of all other JS tests
except tests that are not possible to add without some modifications in
the test infra. See todos on the commented-out test declarations
2022-11-12 16:28:24 +01:00

30 lines
695 B
Kotlin
Vendored

// IGNORE_BACKEND_K2: JVM_IR, JS_IR
// FIR status: don't support legacy feature
// !LANGUAGE: -ProhibitAssigningSingleElementsToVarargsInNamedForm
// TARGET_BACKEND: JVM
// WITH_STDLIB
annotation class Ann(vararg val p: Int)
@Ann(p = 1) class MyClass
fun box(): String {
test(MyClass::class.java, "1")
return "OK"
}
fun test(klass: Class<*>, expected: String) {
val ann = klass.getAnnotation(Ann::class.java)
if (ann == null) throw AssertionError("fail: cannot find Ann on ${klass}")
var result = ""
for (i in ann.p) {
result += i
}
if (result != expected) {
throw AssertionError("fail: expected = ${expected}, actual = ${result}")
}
}