Fix unsound smartcast from loop condition on assigned vars

^KT-22379 Fixed
This commit is contained in:
Dmitry Savvinov
2018-06-21 12:57:36 +03:00
committed by Dmitry Savvinov
parent a7d706f693
commit 447c127036
8 changed files with 85 additions and 2 deletions
@@ -0,0 +1,21 @@
// !LANGUAGE: -SoundSmartcastFromLoopConditionForLoopAssignedVariables
fun foo() {
var x: String? = "123"
while (x!!.length < 42) {
x = null
break
}
<!DEBUG_INFO_SMARTCAST!>x<!>.length // 'x' is unsoundly smartcasted here
}
fun bar() {
var x: List<Int>? = ArrayList<Int>(1)
for (i in x!!) {
x = null
break
}
<!DEBUG_INFO_SMARTCAST!>x<!>.size // 'x' is unsoundly smartcasted here
}