Files
kotlin-fork/compiler/testData/codegen/box/inference/coercionToUnitWithLastLambdaExpression.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
501 B
Kotlin
Vendored

fun <T> myRun(action: () -> T): T = action()
fun foo(): String = "foo"
fun <K> materialize(): K {
result += "K"
return "str" as K
}
var result = "fail"
fun test1(n: Number, b: Boolean) {
n.let {
if (b) return@let
myRun {
result = "O"
foo()
}
}
}
fun test2(n: Number, b: Boolean) {
n.let {
if (b) return@let
materialize()
}
}
fun box(): String {
test1(42, false)
test2(42, false)
return result
}