Support 'when' with subject variable in JVM BE

This commit is contained in:
Dmitry Petrov
2018-06-08 12:51:33 +03:00
parent 148d03e365
commit d6894091a9
9 changed files with 225 additions and 24 deletions
@@ -0,0 +1,17 @@
// !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()
}