Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/loops/assignWhenInsideWhileTrue.kt
T
2015-04-29 14:03:11 +03:00

16 lines
435 B
Kotlin

public fun foo(x: String?): Int {
var y: Any
loop@ while (true) {
y = when (x) {
null -> break@loop
"abc" -> return 0
"xyz" -> return 1
else -> <!DEBUG_INFO_SMARTCAST!>x<!>.length()
}
// y is always Int after when
<!DEBUG_INFO_SMARTCAST!>y<!>: Int
}
// x is null because of the break
return x<!UNSAFE_CALL!>.<!>length()
}