Files
kotlin-fork/compiler/testData/codegen/box/functions/kt3214.kt
T
Svyatoslav Kuzmich b79719d6f5 [Wasm] Fix unit issues
- Materialize unit when its value is actually needed.
- Special-case Unit_getInstance return type at codegen. It should be a
  proper Unit object instead of a "void"
2021-09-08 19:56:26 +03:00

34 lines
503 B
Kotlin
Vendored

class A {
fun get(vararg x: Int) = x.size
}
class B {
fun get(vararg x: Unit) = x.size
}
fun test1(a: A): Int {
return a.get(1)
}
fun test2(a: A): Int {
return a.get(1, 2)
}
fun test3(b: B): Int {
return b.get(Unit, Unit)
}
fun box() : String {
var result = test1(A())
if (result != 1) return "fail1: $result"
result = test2(A())
if (result != 2) return "fail2: $result"
result = test3(B())
if (result != 2) return "fail3: $result"
return "OK"
}