Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/loops/elvisLeftBreakInsideWhileTrue.kt
T
Mikhail Glukhikh e97e792674 Review fixes for smart casts in / out loops.
LoopTypeInfo became TypeInfoWithJumpInfo rewritten in Kotlin.
Fixed a bug with break inside Elvis inside a loop, a pack of related tests added.
isTrueConstant moved to JetPsiUtil.
2015-04-16 20:11:01 +03:00

9 lines
287 B
Kotlin
Vendored

public fun foo(x: String?, y: String?): Int {
while (true) {
(if (x != null) break else y) ?: y!!
// x is not null in both branches
<!DEBUG_INFO_SMARTCAST!>y<!>.length()
}
// y can be null because of the break
return y<!UNSAFE_CALL!>.<!>length()
}