Files
kotlin-fork/compiler/testData/codegen/box/when/whenSubjectVariable/captureSubjectVariable.kt
T
2018-06-20 14:06:34 +03:00

17 lines
315 B
Kotlin
Vendored

// !LANGUAGE: +VariableDeclarationInWhenSubject
// IGNORE_BACKEND: JS
fun box(): String {
var y: String = "OK"
var materializer: (() -> String)? = null
when (val x = y) {
"OK" -> materializer = { x }
else -> return "x is $x"
}
y = "Fail"
return materializer!!.invoke()
}