Files
kotlin-fork/compiler/testData/codegen/box/unit/kt4212.kt
T
Alexander Udalov 6276dd1483 Return Unit.VALUE if Unit or Any is expected
StackValue.coerce will do its job in casting void to Unit correctly

 #KT-4212 Fixed
2013-12-09 17:57:59 +04:00

21 lines
320 B
Kotlin

fun foo(): Any? = bar()
fun bar() {}
fun baz(): Any? {
return bar()
}
fun quux(): Unit? = bar()
fun box(): String {
foo()
if (foo() != Unit.VALUE) return "Fail 1"
if (foo() != bar()) return "Fail 2"
if (bar() != baz()) return "Fail 3"
if (baz() != quux()) return "Fail 4"
return "OK"
}