Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/loops/ifBreakExprInsideWhileTrue.kt
T
Mikhail Glukhikh 27625b04e1 Refactoring of JetTypeInfo / BindingContext. Loop data flow analysis corrected.
Now BindingContext includes expression type info instead of jump out possible, data flow info and expression type.
getType() was added into BindingContext, getType() and recordType() were added into BindingTrace.
JetTypeInfo now includes also jump possible flag and jump point data flow info.
Old TypeInfoWithJumpInfo deleted.
TypeInfoFactory introduced to create JetTypeInfo instances.
A pack of extra tests for break / continue in loops added.
2015-04-21 15:29:07 +03:00

11 lines
322 B
Kotlin

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