Fix unsound smartcast from loop condition on assigned vars
^KT-22379 Fixed
This commit is contained in:
committed by
Dmitry Savvinov
parent
a7d706f693
commit
447c127036
Vendored
+21
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user