SenselessComparisonChecker used for @NotNull values from Java
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -SENSELESS_COMPARISON
|
||||
|
||||
// FILE: p/J.java
|
||||
package p;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// !DIAGNOSTICS: -SENSELESS_COMPARISON
|
||||
|
||||
// FILE: p/J.java
|
||||
package p;
|
||||
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
|
||||
// FILE: p/J.java
|
||||
package p;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
public class J {
|
||||
@NotNull
|
||||
public static J staticNN;
|
||||
@Nullable
|
||||
public static J staticN;
|
||||
public static J staticJ;
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
|
||||
import p.*
|
||||
|
||||
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
|
||||
|
||||
val a: Any? = null
|
||||
|
||||
if (<!SENSELESS_COMPARISON!>platformNN != null<!>) {}
|
||||
if (<!SENSELESS_COMPARISON!>null != platformNN<!>) {}
|
||||
if (<!SENSELESS_COMPARISON!>platformNN == null<!>) {}
|
||||
if (<!SENSELESS_COMPARISON!>null == platformNN<!>) {}
|
||||
|
||||
if (a != null && platformNN != a) {}
|
||||
|
||||
if (platformN != null) {}
|
||||
if (platformN == null) {}
|
||||
if (a == null && platformN == a) {}
|
||||
|
||||
if (platformJ != null) {}
|
||||
if (platformJ == null) {}
|
||||
if (a == null && platformJ == a) {}
|
||||
}
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
internal fun test(): kotlin.Unit
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
|
||||
// FILE: p/J.java
|
||||
package p;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
public class J {
|
||||
@NotNull
|
||||
public static J staticNN;
|
||||
@Nullable
|
||||
public static J staticN;
|
||||
public static J staticJ;
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
|
||||
import p.*
|
||||
|
||||
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
|
||||
|
||||
val a: Any? = null
|
||||
|
||||
if (<!SENSELESS_COMPARISON!>platformNN !== null<!>) {}
|
||||
if (<!SENSELESS_COMPARISON!>null !== platformNN<!>) {}
|
||||
if (<!SENSELESS_COMPARISON!>platformNN === null<!>) {}
|
||||
if (<!SENSELESS_COMPARISON!>null === platformNN<!>) {}
|
||||
|
||||
if (platformN !== null) {}
|
||||
if (platformN === null) {}
|
||||
if (a === null && platformN === a) {}
|
||||
|
||||
if (platformJ !== null) {}
|
||||
if (platformJ === null) {}
|
||||
if (a === null && platformJ === a) {}
|
||||
}
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
internal fun test(): kotlin.Unit
|
||||
Reference in New Issue
Block a user