Files
kotlin-fork/compiler/testData/codegen/box/vararg/singleAssignmentToVarargsInFunction.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

35 lines
754 B
Kotlin
Vendored

// IGNORE_BACKEND_K2: JVM_IR, JS_IR
// !LANGUAGE: -ProhibitAssigningSingleElementsToVarargsInNamedForm -AllowAssigningArrayElementsToVarargsInNamedFormForFunctions
// FIR status: don't support legacy feature
fun box(): String {
if (test1(p = 1) != "1") return "fail 1"
if (test2(p = "1") != "1") return "fail 2"
if (test3(p = "1") != "1") return "fail 3"
return "OK"
}
fun test1(vararg p: Int): String {
var result = ""
for (i in p) {
result += i
}
return result
}
fun test2(vararg p: String): String {
var result = ""
for (i in p) {
result += i
}
return result
}
fun <T> test3(vararg p: T): String {
var result = ""
for (i in p) {
result += i
}
return result
}