Files
kotlin-fork/compiler/testData/codegen/box/when/whenSubjectVariable/captureSubjectVariable.kt
T
Zalim Bashorov 3c765e3625 [JS BE] Support val in when subject
#KT-25014 Fixed
2018-08-09 16:22:25 +03:00

16 lines
293 B
Kotlin
Vendored

// !LANGUAGE: +VariableDeclarationInWhenSubject
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()
}