Add more variable aliasing tests

This commit is contained in:
pyos
2022-11-07 13:10:17 +01:00
committed by teamcity
parent a8bef8ac81
commit 33363ba1fc
8 changed files with 216 additions and 4 deletions
@@ -1,3 +1,5 @@
// SKIP_TXT
fun test() {
var a: Any? = null
var b = a
@@ -63,3 +65,20 @@ fun test2() {
<!DEBUG_INFO_SMARTCAST!>b<!>.length // OK
b.<!UNRESOLVED_REFERENCE!>unaryPlus<!>() // error
}
fun test3() {
var a: Any? = null
val b = a
val c = a
if (a is String) {
<!DEBUG_INFO_SMARTCAST!>a<!>.length // ok
b.<!UNRESOLVED_REFERENCE!>length<!> // ok
c.<!UNRESOLVED_REFERENCE!>length<!> // ok
}
a = null // b and c are still aliases to the same old value
if (b is String) {
a.<!UNRESOLVED_REFERENCE!>length<!> // error
<!DEBUG_INFO_SMARTCAST!>b<!>.length // ok
c.<!UNRESOLVED_REFERENCE!>length<!> // ok
}
}