639a454d6c
For example:
val c = C("...")
val x = c.x // alias to variable for c.x, which depends on c
if (x == null) return
// now c.x has type Any
c = C(null)
// c has been reassigned => info for c.x is no longer valid;
// c itself has never had any statements made about it, but
// we must still call removeAllAboutVariable to clear the
// dependents
41 lines
719 B
Kotlin
Vendored
41 lines
719 B
Kotlin
Vendored
// SKIP_TXT
|
|
|
|
class C(val x: String?)
|
|
|
|
fun test1() {
|
|
var c = C("...")
|
|
val x = c.x
|
|
if (x == null) return
|
|
x.length // ok
|
|
c.x.length // ok
|
|
c = C(null)
|
|
x.length // ok
|
|
c.x<!UNSAFE_CALL!>.<!>length // bad
|
|
}
|
|
|
|
fun test2() {
|
|
var c = C("...")
|
|
val x = c.x
|
|
if (x == null) return
|
|
while (true) {
|
|
x.length // ok
|
|
c.x<!UNSAFE_CALL!>.<!>length // bad
|
|
c = C(null)
|
|
x.length // ok
|
|
c.x<!UNSAFE_CALL!>.<!>length // bad
|
|
}
|
|
}
|
|
|
|
fun test3(p: Boolean) {
|
|
var c = C("...")
|
|
val x = c.x
|
|
if (x == null) return
|
|
x.length // ok
|
|
c.x.length // ok
|
|
if (p) {
|
|
c = C(null)
|
|
}
|
|
x.length // ok
|
|
c.x<!UNSAFE_CALL!>.<!>length // bad
|
|
}
|