FIR checker: differentiate UNSAFE_CALL from INAPPLICABLE_CANDIDATE
To do so, inside the root cause of inapplicable candidate errors, we will record expected/actual type of receiver, if any. That will help identifying inapplicable calls on nullable receiver.
This commit is contained in:
committed by
Mikhail Glukhikh
parent
4b823eca21
commit
e72ddbcbfe
+10
-10
@@ -1,26 +1,26 @@
|
||||
fun foo(x: String?, y: String?, z: String?) {
|
||||
if ((x!!.hashCode() == 0 || y!!.hashCode() == 1) && z!!.hashCode() == 2) {
|
||||
x.length
|
||||
y.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
y.<!UNSAFE_CALL!>length<!>
|
||||
// condition is true => z!! after and is called
|
||||
z.length
|
||||
}
|
||||
else {
|
||||
x.length
|
||||
y.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
z.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
y.<!UNSAFE_CALL!>length<!>
|
||||
z.<!UNSAFE_CALL!>length<!>
|
||||
}
|
||||
// First element is always analyzed
|
||||
x.length
|
||||
var xx = y ?: z
|
||||
if ((xx!!.hashCode() == 0 && y!!.hashCode() == 1) || z!!.hashCode() == 2) {
|
||||
xx.length
|
||||
y.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
z.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
y.<!UNSAFE_CALL!>length<!>
|
||||
z.<!UNSAFE_CALL!>length<!>
|
||||
}
|
||||
else {
|
||||
xx.length
|
||||
y.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
y.<!UNSAFE_CALL!>length<!>
|
||||
// condition is false => z!! after or is called
|
||||
z.length
|
||||
}
|
||||
@@ -35,16 +35,16 @@ fun foo(x: String?, y: String?, z: String?) {
|
||||
}
|
||||
else {
|
||||
xx.length
|
||||
y.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
z.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
y.<!UNSAFE_CALL!>length<!>
|
||||
z.<!UNSAFE_CALL!>length<!>
|
||||
}
|
||||
// First element is always analyzed
|
||||
x.length
|
||||
xx = y ?: z
|
||||
if (xx!!.hashCode() == 0 || y!!.hashCode() == 1 || z!!.hashCode() == 2) {
|
||||
xx.length
|
||||
y.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
z.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
y.<!UNSAFE_CALL!>length<!>
|
||||
z.<!UNSAFE_CALL!>length<!>
|
||||
}
|
||||
else {
|
||||
// all three are called
|
||||
|
||||
Reference in New Issue
Block a user