FIR checker: report UNSAFE_CALL for overloaded function calls
Previously if an unsafe call is to an overloaded function, FIR checkers report NONE_APPLICABLE. This change instead report them as UNSAFE_CALL or its variants.
This commit is contained in:
committed by
Mikhail Glukhikh
parent
92df1f575a
commit
454ae3b17a
-41
@@ -1,41 +0,0 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
class A() {
|
||||
operator infix fun plus(i : Int) {}
|
||||
operator fun unaryMinus() {}
|
||||
operator infix fun contains(a : Any?) : Boolean = true
|
||||
}
|
||||
|
||||
operator infix fun A.div(i : Int) {}
|
||||
operator infix fun A?.times(i : Int) {}
|
||||
|
||||
fun test(x : Int?, a : A?) {
|
||||
x.<!NONE_APPLICABLE!>plus<!>(1)
|
||||
x?.plus(1)
|
||||
x <!NONE_APPLICABLE!>+<!> 1
|
||||
<!UNSAFE_CALL!>-<!>x
|
||||
x<!UNSAFE_CALL!>.<!>unaryMinus()
|
||||
x?.unaryMinus()
|
||||
|
||||
a<!UNSAFE_CALL!>.<!>plus(1)
|
||||
a?.plus(1)
|
||||
a <!UNSAFE_INFIX_CALL!>plus<!> 1
|
||||
a <!UNSAFE_OPERATOR_CALL!>+<!> 1
|
||||
<!UNSAFE_CALL!>-<!>a
|
||||
a<!UNSAFE_CALL!>.<!>unaryMinus()
|
||||
a?.unaryMinus()
|
||||
|
||||
a<!UNSAFE_CALL!>.<!>div(1)
|
||||
a <!UNSAFE_OPERATOR_CALL!>/<!> 1
|
||||
a <!UNSAFE_INFIX_CALL!>div<!> 1
|
||||
a?.div(1)
|
||||
|
||||
a.times(1)
|
||||
a * 1
|
||||
a times 1
|
||||
a?.times(1)
|
||||
|
||||
1 <!UNSAFE_OPERATOR_CALL!>in<!> a
|
||||
a <!UNSAFE_INFIX_CALL!>contains<!> 1
|
||||
a<!UNSAFE_CALL!>.<!>contains(1)
|
||||
a?.contains(1)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !WITH_NEW_INFERENCE
|
||||
class A() {
|
||||
operator infix fun plus(i : Int) {}
|
||||
|
||||
Vendored
+2
-2
@@ -2,7 +2,7 @@ fun test() {
|
||||
val out : Int? = null
|
||||
val x : Nothing? = null
|
||||
if (out != x)
|
||||
out.<!NONE_APPLICABLE!>plus<!>(1)
|
||||
out<!UNSAFE_CALL!>.<!>plus(1)
|
||||
if (out == x) return
|
||||
out.<!NONE_APPLICABLE!>plus<!>(1)
|
||||
out<!UNSAFE_CALL!>.<!>plus(1)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ fun foo() {
|
||||
val y: Int? = 0
|
||||
val z: Int? = 0
|
||||
bar(<!ARGUMENT_TYPE_MISMATCH!>if (y != null) y else z<!>, <!ARGUMENT_TYPE_MISMATCH!>y<!>)
|
||||
y <!NONE_APPLICABLE!>+<!> 2
|
||||
y <!UNSAFE_OPERATOR_CALL!>+<!> 2
|
||||
baz(<!ARGUMENT_TYPE_MISMATCH!>y<!>, <!ARGUMENT_TYPE_MISMATCH!>y<!>, if (y == null) return else y, y)
|
||||
baz(y, z!!, z, y)
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ package example
|
||||
fun test() {
|
||||
val p = test.Public()
|
||||
if (p.public is Int) p.public + 1
|
||||
if (p.<!HIDDEN!>protected<!> is Int) p.<!HIDDEN!>protected<!> <!NONE_APPLICABLE!>+<!> 1
|
||||
if (p.<!HIDDEN!>protected<!> is Int) p.<!HIDDEN!>protected<!> <!UNSAFE_OPERATOR_CALL!>+<!> 1
|
||||
if (p.internal is Int) p.internal + 1
|
||||
val i = test.Internal()
|
||||
if (i.public is Int) i.public + 1
|
||||
if (i.<!HIDDEN!>protected<!> is Int) i.<!HIDDEN!>protected<!> <!NONE_APPLICABLE!>+<!> 1
|
||||
if (i.<!HIDDEN!>protected<!> is Int) i.<!HIDDEN!>protected<!> <!UNSAFE_OPERATOR_CALL!>+<!> 1
|
||||
if (i.internal is Int) i.internal + 1
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -13,15 +13,15 @@ class B {
|
||||
|
||||
fun f() {
|
||||
a = A()
|
||||
a.<!NONE_APPLICABLE!>f<!>(true)
|
||||
takeInt(a.<!NONE_APPLICABLE!>f<!>(""))
|
||||
a<!UNSAFE_CALL!>.<!>f(true)
|
||||
takeInt(a<!UNSAFE_CALL!>.<!>f(""))
|
||||
a.<!NONE_APPLICABLE!>f<!>()
|
||||
}
|
||||
|
||||
fun g() {
|
||||
takeInt(if (3 > 2) {
|
||||
a = A()
|
||||
a.<!NONE_APPLICABLE!>f<!>(true)
|
||||
a<!UNSAFE_CALL!>.<!>f(true)
|
||||
} else {
|
||||
6
|
||||
})
|
||||
|
||||
+1
-1
@@ -9,6 +9,6 @@ var a: A? = null
|
||||
|
||||
fun smartCastInterference(b: B) {
|
||||
if (a != null) {
|
||||
a.<!NONE_APPLICABLE!>foo<!>(b)
|
||||
a<!UNSAFE_CALL!>.<!>foo(b)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user