FIR checker: introduce NO_(GET|SET)_METHOD
Besides introducing new diagnostics, this commit unifies source usages for array accesses in PSI & LT.
This commit is contained in:
committed by
Mikhail Glukhikh
parent
651fd4ad9f
commit
e1c80ac75c
@@ -128,7 +128,7 @@ class Test() {
|
||||
|
||||
(f@ a)[3] = 4
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>this[54] = 34<!>
|
||||
this<!NO_SET_METHOD!>[54]<!> = 34
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -12,5 +12,5 @@ class C<T> {
|
||||
}
|
||||
|
||||
fun test(a: C<out CharSequence>) {
|
||||
<!INAPPLICABLE_CANDIDATE!>a[1] = 25<!>
|
||||
<!INAPPLICABLE_CANDIDATE!>a[1]<!> = 25
|
||||
}
|
||||
|
||||
@@ -31,5 +31,5 @@ fun test() {
|
||||
D[0] = ""
|
||||
D[0] = 2.72
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>Z[0] = ""<!>
|
||||
<!INAPPLICABLE_CANDIDATE!>Z[0]<!> = ""
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@ class A {
|
||||
operator fun set(x: String, value: Int) {}
|
||||
|
||||
fun d(x: Int) {
|
||||
<!INAPPLICABLE_CANDIDATE!>this["", 1] = 1<!>
|
||||
<!INAPPLICABLE_CANDIDATE!>this["", 1]<!> = 1
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
fun test(): Array<Int> {
|
||||
[1, 2]
|
||||
<!UNRESOLVED_REFERENCE!>[1, 2][0]<!>
|
||||
[1, 2]<!NO_GET_METHOD!>[0]<!>
|
||||
[1, 2].<!UNRESOLVED_REFERENCE!>get<!>(0)
|
||||
|
||||
foo([""])
|
||||
|
||||
Vendored
+1
-1
@@ -9,6 +9,6 @@ class A<T> {
|
||||
|
||||
fun test(a: A<out CharSequence>) {
|
||||
a <!INAPPLICABLE_CANDIDATE!>+<!> ""
|
||||
<!INAPPLICABLE_CANDIDATE!>a[1] = ""<!>
|
||||
<!INAPPLICABLE_CANDIDATE!>a[1]<!> = ""
|
||||
<!INAPPLICABLE_CANDIDATE!>a[""]<!>
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -11,7 +11,7 @@ class Out<out F>
|
||||
|
||||
fun test(a: A<out CharSequence>, y: Out<CharSequence>) {
|
||||
a <!INAPPLICABLE_CANDIDATE!>+<!> y
|
||||
<!INAPPLICABLE_CANDIDATE!>a[1] = y<!>
|
||||
<!INAPPLICABLE_CANDIDATE!>a[1]<!> = y
|
||||
<!INAPPLICABLE_CANDIDATE!>a[y]<!>
|
||||
|
||||
a + Out<Nothing>()
|
||||
|
||||
Vendored
+1
-1
@@ -4,5 +4,5 @@ package bar
|
||||
fun main() {
|
||||
class Some
|
||||
|
||||
Some[<!SYNTAX!><!>] <!UNRESOLVED_REFERENCE!>names<!> <!UNRESOLVED_REFERENCE!><!SYNTAX!>=<!> ["ads"]<!>
|
||||
Some[<!SYNTAX!><!>] <!UNRESOLVED_REFERENCE!>names<!> <!SYNTAX!>=<!> <!NO_GET_METHOD!>["ads"]<!>
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
//KT-4866 Resolve does not work inside brackets with unresolved reference before
|
||||
|
||||
fun test(i: Int, j: Int) {
|
||||
<!UNRESOLVED_REFERENCE!><!UNRESOLVED_REFERENCE!>foo<!>[i, j]<!>
|
||||
}
|
||||
<!UNRESOLVED_REFERENCE!>foo<!><!NO_GET_METHOD!>[i, j]<!>
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ fun case_1(a: MutableList<out MutableList<MutableList<MutableList<MutableList<Mu
|
||||
if (f != null) {
|
||||
val g = f[0]
|
||||
if (g != null) {
|
||||
val h = <!UNRESOLVED_REFERENCE!>g[0]<!>
|
||||
val h = g<!NO_GET_METHOD!>[0]<!>
|
||||
if (h != null) {
|
||||
h.<!UNRESOLVED_REFERENCE!>inc<!>()
|
||||
}
|
||||
@@ -43,7 +43,7 @@ fun case_2(a: MutableList<out MutableList<MutableList<MutableList<out MutableLis
|
||||
if (f != null) {
|
||||
val g = f[0]
|
||||
if (g != null) {
|
||||
val h = <!UNRESOLVED_REFERENCE!>g[0]<!> // no SMARTCAST diagnostic
|
||||
val h = g<!NO_GET_METHOD!>[0]<!> // no SMARTCAST diagnostic
|
||||
if (h != null) {
|
||||
h.<!UNRESOLVED_REFERENCE!>inc<!>()
|
||||
}
|
||||
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
// FILE: J.java
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
public class J {
|
||||
@NotNull
|
||||
public static Integer[] staticNN;
|
||||
@Nullable
|
||||
public static Integer[] staticN;
|
||||
public static Integer[] staticJ;
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
|
||||
fun test() {
|
||||
// @NotNull platform type
|
||||
val platformNN = J.staticNN
|
||||
// @Nullable platform type
|
||||
val platformN = J.staticN
|
||||
// platform type with no annotation
|
||||
val platformJ = J.staticJ
|
||||
|
||||
platformNN[0]
|
||||
<!UNSAFE_CALL!>platformN[0]<!>
|
||||
platformJ[0]
|
||||
|
||||
platformNN[0] = 1
|
||||
<!UNSAFE_CALL!>platformN[0] = 1<!>
|
||||
platformJ[0] = 1
|
||||
}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: J.java
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
Vendored
-31
@@ -1,31 +0,0 @@
|
||||
// FILE: J.java
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
public class J {
|
||||
@NotNull
|
||||
public static int[] staticNN;
|
||||
@Nullable
|
||||
public static int[] staticN;
|
||||
public static int[] staticJ;
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
|
||||
fun test() {
|
||||
// @NotNull platform type
|
||||
val platformNN = J.staticNN
|
||||
// @Nullable platform type
|
||||
val platformN = J.staticN
|
||||
// platform type with no annotation
|
||||
val platformJ = J.staticJ
|
||||
|
||||
platformNN[0]
|
||||
<!UNSAFE_CALL!>platformN[0]<!>
|
||||
platformJ[0]
|
||||
|
||||
platformNN[0] = 1
|
||||
<!UNSAFE_CALL!>platformN[0] = 1<!>
|
||||
platformJ[0] = 1
|
||||
}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: J.java
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
@@ -7,6 +7,6 @@ fun foo(a: MutableMap<String, String>, x: String?) {
|
||||
}
|
||||
|
||||
fun foo1(a: MutableMap<String, String>, x: String?) {
|
||||
<!INAPPLICABLE_CANDIDATE!>a[x] = x!!<!>
|
||||
<!INAPPLICABLE_CANDIDATE!>a[x]<!> = x!!
|
||||
a[x!!] = x
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user