Add more variable aliasing tests
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user