Files
kotlin-fork/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.kt
T
Alexander Udalov 1071919706 Remove backend tests on old inference
Also remove any mentions of NewInference, and rename some tests.
2021-11-09 20:07:33 +01:00

21 lines
628 B
Kotlin
Vendored

fun sum(vararg args: Int): Int {
var result = 0
for (arg in args)
result += arg
return result
}
fun nsum(vararg args: Number) = sum(*IntArray(args.size) { args[it].toInt() })
fun zap(vararg b: String, k: Int = 42) {}
fun usePlainArgs(fn: (Int, Int) -> Int) {}
fun usePrimitiveArray(fn: (IntArray) -> Int) {}
fun useArray(fn: (Array<Int>) -> Int) {}
fun useStringArray(fn: (Array<String>) -> Unit) {}
fun testPlainArgs() { usePlainArgs(::sum) }
fun testPrimitiveArrayAsVararg() { usePrimitiveArray(::sum) }
fun testArrayAsVararg() { useArray(::nsum) }
fun testArrayAndDefaults() { useStringArray(::zap) }