Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/varnotnull/whileTrueWithBracketSet.kt
T
Mikhail Glukhikh 109e0abb6d Review fixes for mutable variable smart casting (mostly refactoring).
DataFlowValue.isPredictable() introduced instead of isStableIdentifier().
Parenthesized assignments are treated correctly.
2015-04-16 20:11:03 +03:00

13 lines
318 B
Kotlin

fun x(): Boolean { return true }
public fun foo(pp: String?): Int {
var p = pp
while(true) {
p!!.length()
if (x()) break
(((p))) = null
}
// Smart cast is NOT possible here
// (we could provide it but p = null makes it much harder)
return p<!UNSAFE_CALL!>.<!>length()
}