[FIR] Consider stability of receiver for DFA variables
^KT-57425 Fixed
This commit is contained in:
committed by
Space Team
parent
d579798169
commit
1936658e40
+14
@@ -0,0 +1,14 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-57425
|
||||
// WITH_STDLIB
|
||||
|
||||
data class Data(val x: Int?)
|
||||
|
||||
fun test(pair: Pair<String?, Data>) {
|
||||
if (pair.second.x != null) {
|
||||
<!SMARTCAST_IMPOSSIBLE!>pair.second.x<!>.inc() // should be an error
|
||||
}
|
||||
if (pair.first != null) {
|
||||
<!SMARTCAST_IMPOSSIBLE!>pair.first<!>.length // should be an error
|
||||
}
|
||||
}
|
||||
Vendored
+80
@@ -0,0 +1,80 @@
|
||||
// SKIP_TXT
|
||||
|
||||
class C {
|
||||
val x: String?
|
||||
get() = null
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
var c = C()
|
||||
val x = c.x
|
||||
if (x == null) return
|
||||
x.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
c = C()
|
||||
x.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
var c = C()
|
||||
val x = c.x
|
||||
if (x == null) return
|
||||
while (true) {
|
||||
x.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
c = C()
|
||||
x.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
}
|
||||
}
|
||||
|
||||
fun test3(p: Boolean) {
|
||||
var c = C()
|
||||
val x = c.x
|
||||
if (x == null) return
|
||||
x.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
if (p) {
|
||||
c = C()
|
||||
}
|
||||
x.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
}
|
||||
|
||||
fun test4(p: Boolean, q: Boolean) {
|
||||
var c = C()
|
||||
val x = c.x
|
||||
if (x == null) return
|
||||
x.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
if (p) {
|
||||
if (q) {
|
||||
c = C()
|
||||
} else {
|
||||
c = C()
|
||||
}
|
||||
} else {
|
||||
if (q) {
|
||||
c = C()
|
||||
} else {
|
||||
c = C()
|
||||
}
|
||||
}
|
||||
x.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
}
|
||||
|
||||
fun test5() {
|
||||
var c = C()
|
||||
val d = c
|
||||
val x = d.x
|
||||
if (x == null) return
|
||||
x.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
d.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
c = C()
|
||||
x.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
d.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
// SKIP_TXT
|
||||
|
||||
class C {
|
||||
val x: String?
|
||||
get() = null
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
var c = C()
|
||||
val x = c.x
|
||||
if (x == null) return
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
c = C()
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
var c = C()
|
||||
val x = c.x
|
||||
if (x == null) return
|
||||
while (true) {
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
c = C()
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
}
|
||||
}
|
||||
|
||||
fun test3(p: Boolean) {
|
||||
var c = C()
|
||||
val x = c.x
|
||||
if (x == null) return
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
if (p) {
|
||||
c = C()
|
||||
}
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
}
|
||||
|
||||
fun test4(p: Boolean, q: Boolean) {
|
||||
var c = C()
|
||||
val x = c.x
|
||||
if (x == null) return
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
if (p) {
|
||||
if (q) {
|
||||
c = C()
|
||||
} else {
|
||||
c = C()
|
||||
}
|
||||
} else {
|
||||
if (q) {
|
||||
c = C()
|
||||
} else {
|
||||
c = C()
|
||||
}
|
||||
}
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
}
|
||||
|
||||
fun test5() {
|
||||
var c = C()
|
||||
val d = c
|
||||
val x = d.x
|
||||
if (x == null) return
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
<!SMARTCAST_IMPOSSIBLE!>d.x<!>.length // no smartcast
|
||||
c = C()
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length // smartcast
|
||||
c.x<!UNSAFE_CALL!>.<!>length // no smartcast
|
||||
<!SMARTCAST_IMPOSSIBLE!>d.x<!>.length // no smartcast
|
||||
}
|
||||
Reference in New Issue
Block a user