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:
Jinseong Jeon
2021-01-26 16:03:27 -08:00
committed by Mikhail Glukhikh
parent 4b823eca21
commit e72ddbcbfe
275 changed files with 1426 additions and 1388 deletions
@@ -5,7 +5,7 @@ public class X {
public fun fn(): Int {
if (y != null)
// With non-default getter smartcast is not possible
return y.<!INAPPLICABLE_CANDIDATE!>length<!>
return y.<!UNSAFE_CALL!>length<!>
else
return 0
}
@@ -7,5 +7,5 @@ infix fun Int.bar(i: Int) = i
fun test() {
val p = A()
// For open value properties, smart casts should not work
if (p.foo is Int) p.foo <!INAPPLICABLE_CANDIDATE!>bar<!> 11
if (p.foo is Int) p.foo <!UNSAFE_CALL!>bar<!> 11
}
@@ -4,10 +4,10 @@ public class X {
public fun fn(): Int {
if (x != null)
// Smartcast is not possible for variable properties
return x.<!INAPPLICABLE_CANDIDATE!>length<!>
return x.<!UNSAFE_CALL!>length<!>
else if (y != null)
// Even if they are private
return y.<!INAPPLICABLE_CANDIDATE!>length<!>
return y.<!UNSAFE_CALL!>length<!>
else
return 0
}