Files
kotlin-fork/compiler/testData/codegen/box/annotations/singleAssignmentToVarargInAnnotation.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

29 lines
645 B
Kotlin
Vendored

// IGNORE_BACKEND_FIR: JVM_IR
// !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}")
}
}