FIR checker: differentiate UNSAFE_IMPLICIT_INVOKE_CALL from UNSAFE_CALL

This commit is contained in:
Jinseong Jeon
2021-02-01 10:36:33 -08:00
committed by Dmitriy Novozhilov
parent 0c0c53cc2e
commit 5e150d62ea
21 changed files with 73 additions and 106 deletions
@@ -9,13 +9,13 @@ interface T {
}
fun test(t: T) {
t<!UNSAFE_CALL!>.<!>f(1) //unsafe call error
t.<!UNSAFE_IMPLICIT_INVOKE_CALL!>f<!>(1) //unsafe call error
t.f?.invoke(1)
}
fun test1(t: T?) {
t.<!UNRESOLVED_REFERENCE!>f<!>(1) // todo resolve f as value and report UNSAFE_CALL
t?.<!UNSAFE_CALL!>f<!>(1)
t?.<!UNSAFE_IMPLICIT_INVOKE_CALL!>f<!>(1)
t<!UNSAFE_CALL!>.<!>f?.invoke(1)
t?.f?.invoke(1)
}
@@ -1,23 +0,0 @@
// FILE: J.java
import org.jetbrains.annotations.*;
public class J {
public interface Invoke {
void invoke();
}
@NotNull
public static Invoke staticNN;
@Nullable
public static Invoke staticN;
public static Invoke staticJ;
}
// FILE: k.kt
fun test() {
J.staticNN()
J<!UNSAFE_CALL!>.<!>staticN()
J.staticJ()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FILE: J.java
import org.jetbrains.annotations.*;
@@ -4,7 +4,7 @@
operator fun String.invoke(i: Int) {}
fun foo(s: String?) {
<!UNSAFE_CALL!>s<!>(1)
<!UNSAFE_IMPLICIT_INVOKE_CALL!>s<!>(1)
<!UNSAFE_CALL!>(s ?: null)(1)<!>
<!UNSAFE_IMPLICIT_INVOKE_CALL!>(s ?: null)(1)<!>
}
@@ -7,8 +7,8 @@ fun test(a: A) {
(a.x)("")
}
"".<!UNRESOLVED_REFERENCE!>(a.x)()<!>
a<!UNSAFE_CALL!>.<!>x("")
<!UNSAFE_CALL!>(a.x)("")<!>
a.<!UNSAFE_IMPLICIT_INVOKE_CALL!>x<!>("")
<!UNSAFE_IMPLICIT_INVOKE_CALL!>(a.x)("")<!>
with("") {
a.<!INAPPLICABLE_CANDIDATE!>x<!>()
@@ -14,7 +14,7 @@ class MemberInvokeOwner {
class Cls {
fun testImplicitReceiver() {
<!UNSAFE_CALL!>nullableExtensionProperty<!>()
<!UNSAFE_IMPLICIT_INVOKE_CALL!>nullableExtensionProperty<!>()
}
}
@@ -30,7 +30,7 @@ fun testNullableReceiver(nullable: Cls?) {
}
fun testNotNullableReceiver(notNullable: Cls) {
notNullable<!UNSAFE_CALL!>.<!>nullableExtensionProperty()
notNullable.<!UNSAFE_IMPLICIT_INVOKE_CALL!>nullableExtensionProperty<!>()
notNullable?.extensionProperty()
}
@@ -38,6 +38,6 @@ fun testFlexibleReceiver() {
val flexible = JavaClass.createFlexible()
flexible.extensionProperty()
flexible?.extensionProperty()
flexible<!UNSAFE_CALL!>.<!>nullableExtensionProperty()
flexible?.<!UNSAFE_CALL!>nullableExtensionProperty<!>()
flexible.<!UNSAFE_IMPLICIT_INVOKE_CALL!>nullableExtensionProperty<!>()
flexible?.<!UNSAFE_IMPLICIT_INVOKE_CALL!>nullableExtensionProperty<!>()
}
+2 -2
View File
@@ -1,7 +1,7 @@
// !WITH_NEW_INFERENCE
fun f(s: String, action: (String.() -> Unit)?) {
s.foo().bar()<!UNSAFE_CALL!>.<!>action()
s.foo().bar().<!UNSAFE_IMPLICIT_INVOKE_CALL!>action<!>()
}
fun String.foo() = ""
@@ -12,4 +12,4 @@ fun String.bar() = ""
val functions: Map<String, () -> Any> = TODO()
fun run(name: String) = <!UNSAFE_CALL!>functions[name]()<!>
fun run(name: String) = <!UNSAFE_IMPLICIT_INVOKE_CALL!>functions[name]()<!>