Add test for KT-54744

This commit is contained in:
pyos
2022-11-01 12:44:28 +01:00
committed by teamcity
parent a926edd845
commit 31eaa211b7
6 changed files with 104 additions and 0 deletions
@@ -0,0 +1,40 @@
// SKIP_TXT
class C(val x: String?)
fun test1() {
var c = C("...")
val x = c.x
if (x == null) return
<!DEBUG_INFO_SMARTCAST!>x<!>.length // ok
c.x<!UNSAFE_CALL!>.<!>length // ok
c = C(null)
<!DEBUG_INFO_SMARTCAST!>x<!>.length // ok
c.x<!UNSAFE_CALL!>.<!>length // bad
}
fun test2() {
var c = C("...")
val x = c.x
if (x == null) return
while (true) {
<!DEBUG_INFO_SMARTCAST!>x<!>.length // ok
c.x<!UNSAFE_CALL!>.<!>length // bad
c = C(null)
<!DEBUG_INFO_SMARTCAST!>x<!>.length // ok
c.x<!UNSAFE_CALL!>.<!>length // bad
}
}
fun test3(p: Boolean) {
var c = C("...")
val x = c.x
if (x == null) return
<!DEBUG_INFO_SMARTCAST!>x<!>.length // ok
c.x<!UNSAFE_CALL!>.<!>length // ok
if (p) {
c = C(null)
}
<!DEBUG_INFO_SMARTCAST!>x<!>.length // ok
c.x<!UNSAFE_CALL!>.<!>length // bad
}