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() {
|
||||
b.length // OK
|
||||
b.<!UNRESOLVED_REFERENCE!>unaryPlus<!>() // error
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
var a: Any? = null
|
||||
val b = a
|
||||
val c = a
|
||||
if (a is String) {
|
||||
a.length // ok
|
||||
b.length // ok
|
||||
c.length // ok
|
||||
}
|
||||
a = null // b and c are still aliases to the same old value
|
||||
if (b is String) {
|
||||
a.<!UNRESOLVED_REFERENCE!>length<!> // error
|
||||
b.length // ok
|
||||
c.<!UNRESOLVED_REFERENCE!>length<!> // ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
public fun test2(): kotlin.Unit
|
||||
+14
@@ -61,3 +61,17 @@ fun test4(p: Boolean, q: Boolean) {
|
||||
x.length // ok
|
||||
c.x<!UNSAFE_CALL!>.<!>length // bad
|
||||
}
|
||||
|
||||
fun test5() {
|
||||
var c = C("...")
|
||||
val d = c
|
||||
val x = d.x
|
||||
if (x == null) return
|
||||
x.length // ok
|
||||
c.x.length // ok
|
||||
d.x.length // ok
|
||||
c = C(null)
|
||||
x.length // ok
|
||||
c.x<!UNSAFE_CALL!>.<!>length // bad
|
||||
d.x<!UNSAFE_CALL!>.<!>length // ok
|
||||
}
|
||||
|
||||
+14
@@ -61,3 +61,17 @@ fun test4(p: Boolean, q: Boolean) {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length // ok
|
||||
c.x<!UNSAFE_CALL!>.<!>length // bad
|
||||
}
|
||||
|
||||
fun test5() {
|
||||
var c = C("...")
|
||||
val d = c
|
||||
val x = d.x
|
||||
if (x == null) return
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length // ok
|
||||
c.x<!UNSAFE_CALL!>.<!>length // ok
|
||||
<!DEBUG_INFO_SMARTCAST!>d.x<!>.length // ok
|
||||
c = C(null)
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length // ok
|
||||
c.x<!UNSAFE_CALL!>.<!>length // bad
|
||||
<!DEBUG_INFO_SMARTCAST!>d.x<!>.length // ok
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user