FIR: report UNSAFE_CALL on dot when possible
This commit is contained in:
Vendored
+13
-13
@@ -14,15 +14,15 @@ fun test1() {
|
||||
try {
|
||||
x = null
|
||||
} catch (e: Exception) {
|
||||
x.<!UNSAFE_CALL!>length<!> // smartcast shouldn't be allowed (OOME could happen after `x = null`)
|
||||
x<!UNSAFE_CALL!>.<!>length // smartcast shouldn't be allowed (OOME could happen after `x = null`)
|
||||
throw e
|
||||
}
|
||||
finally {
|
||||
// smartcast shouldn't be allowed, `x = null` could've happened
|
||||
x.<!UNSAFE_CALL!>length<!>
|
||||
x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
// smartcast shouldn't be allowed, `x = null` could've happened
|
||||
x.<!UNSAFE_CALL!>length<!>
|
||||
x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
// With old DFA of try/catch info about unsound smartcasts after try
|
||||
@@ -35,12 +35,12 @@ fun test2() {
|
||||
x = null
|
||||
} catch (e: Exception) {
|
||||
// BAD
|
||||
x.<!UNSAFE_CALL!>length<!>
|
||||
x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
finally {
|
||||
x.<!UNSAFE_CALL!>length<!>
|
||||
x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
x.<!UNSAFE_CALL!>length<!>
|
||||
x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
@@ -51,7 +51,7 @@ fun test3() {
|
||||
} catch (e: Exception) {
|
||||
t2 = null
|
||||
}
|
||||
t2.<!UNSAFE_CALL!>not<!>() // wrong smartcast, NPE
|
||||
t2<!UNSAFE_CALL!>.<!>not() // wrong smartcast, NPE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ fun test4() {
|
||||
try {
|
||||
t2 = null
|
||||
} finally { }
|
||||
t2.<!UNSAFE_CALL!>not<!>() // wrong smartcast, NPE
|
||||
t2<!UNSAFE_CALL!>.<!>not() // wrong smartcast, NPE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,10 +82,10 @@ fun test5() {
|
||||
}
|
||||
finally {
|
||||
s1.length
|
||||
s2.<!UNSAFE_CALL!>length<!>
|
||||
s2<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
s1.length
|
||||
s2.<!UNSAFE_CALL!>length<!>
|
||||
s2<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test6(s1: String?, s2: String?) {
|
||||
@@ -99,10 +99,10 @@ fun test6(s1: String?, s2: String?) {
|
||||
return
|
||||
}
|
||||
finally {
|
||||
s.<!UNSAFE_CALL!>length<!>
|
||||
s<!UNSAFE_CALL!>.<!>length
|
||||
requireNotNull(s2)
|
||||
}
|
||||
s.<!UNSAFE_CALL!>length<!>
|
||||
s1.<!UNSAFE_CALL!>length<!>
|
||||
s<!UNSAFE_CALL!>.<!>length
|
||||
s1<!UNSAFE_CALL!>.<!>length
|
||||
s2.length
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user