Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/loops/elvisIfBreakInsideWhileTrue.kt
T
2021-10-21 19:39:51 +03:00

10 lines
295 B
Kotlin
Vendored

public fun foo(x: String?, y: String?): Int {
while (true) {
x ?: <!INVALID_IF_AS_EXPRESSION_WARNING!>if<!> (y == null) break
// y is nullable if x != null
y<!UNSAFE_CALL!>.<!>length
}
// y is null because of the break
return y<!UNSAFE_CALL!>.<!>length
}