[FIR] Implement warnings for java nullability type mismatch
#KT-56989
This commit is contained in:
committed by
Space Team
parent
1ecbc094ec
commit
a6fdeeb7df
-25
@@ -1,25 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
// FILE: sandbox/module-info.java
|
||||
import org.jspecify.nullness.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
module sandbox {
|
||||
requires java9_annotations;
|
||||
exports test;
|
||||
}
|
||||
|
||||
// FILE: sandbox/test/Test.java
|
||||
package test;
|
||||
|
||||
public class Test {
|
||||
public void foo(Integer x) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
import test.Test
|
||||
|
||||
fun main(x: Test) {
|
||||
x.foo(null)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
// FILE: sandbox/test/module-info.java
|
||||
import org.jspecify.nullness.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
module sandbox {
|
||||
requires java9_annotations;
|
||||
exports test;
|
||||
}
|
||||
|
||||
// FILE: sandbox/test/Test.java
|
||||
package test;
|
||||
|
||||
import org.jspecify.nullness.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class Test {
|
||||
public void foo(Integer x) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
import test.Test
|
||||
|
||||
fun main(x: Test) {
|
||||
x.foo(null)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
// FILE: sandbox/module-info.java
|
||||
import org.jspecify.nullness.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
module sandbox {
|
||||
requires java9_annotations;
|
||||
exports test;
|
||||
}
|
||||
|
||||
// FILE: sandbox/test/package-info.java
|
||||
@NullMarked
|
||||
package test;
|
||||
|
||||
import org.jspecify.nullness.NullMarked;
|
||||
|
||||
// FILE: sandbox/test/Test.java
|
||||
package test;
|
||||
|
||||
public class Test {
|
||||
public void foo(Integer x) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
import test.Test
|
||||
|
||||
fun main(x: Test) {
|
||||
x.foo(null)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
// MODULE: module1
|
||||
// FILE: module1/module-info.java
|
||||
module module1 {
|
||||
}
|
||||
|
||||
// MODULE: module2(module1)
|
||||
// FILE: module2/module-info.java
|
||||
import org.jspecify.nullness.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
module module2 {
|
||||
requires java9_annotations;
|
||||
requires module1;
|
||||
exports test2;
|
||||
}
|
||||
|
||||
// FILE: module2/test2/Test.java
|
||||
package test2;
|
||||
|
||||
public class Test {
|
||||
public void foo(Integer x) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(y: test2.Test) {
|
||||
y.foo(null)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
// FILE: my.sand.box/module-info.java
|
||||
import org.jspecify.nullness.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
open module my.sand.box {
|
||||
requires java9_annotations;
|
||||
exports my.test;
|
||||
}
|
||||
|
||||
// FILE: my.sand.box/my/test/Test.java
|
||||
package my.test;
|
||||
|
||||
public class Test {
|
||||
public void foo(Integer x) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
import my.test.Test
|
||||
|
||||
fun main(x: Test) {
|
||||
x.foo(null)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
// MODULE: module1
|
||||
// FILE: module1/module-info.java
|
||||
import org.jspecify.nullness.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
module module1 {
|
||||
requires java9_annotations;
|
||||
exports test1;
|
||||
}
|
||||
|
||||
// FILE: module1/test1/Test1.java
|
||||
package test1;
|
||||
|
||||
public class Test1 {
|
||||
public void foo(Integer x) {}
|
||||
}
|
||||
|
||||
// MODULE: module2(module1)
|
||||
// FILE: module2/module-info.java
|
||||
module module2 {
|
||||
requires module1;
|
||||
exports test2;
|
||||
}
|
||||
|
||||
// FILE: module2/test2/Test2.java
|
||||
package test2;
|
||||
|
||||
import test1.Test1;
|
||||
|
||||
public class Test2 extends Test1 {
|
||||
public void foo2(Integer x) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
import test1.Test1
|
||||
import test2.Test2
|
||||
|
||||
fun main(x: Test1, y: Test2) {
|
||||
x.foo(null)
|
||||
y.foo(null)
|
||||
y.foo2(null)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
|
||||
+4
-4
@@ -35,9 +35,9 @@ public class Test {
|
||||
import test.Test
|
||||
|
||||
fun main(x: Test) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int..kotlin.Int?!")!>x.Test3().foo(null)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int..kotlin.Int?!")!>x.Test3().Test5().foo(null)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int..kotlin.Int?!")!>x.Test3().foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int..kotlin.Int?!")!>x.Test3().Test5().foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)<!>
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int..kotlin.Int?!")!>Test.Test2().foo(null)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int..kotlin.Int?!")!>Test.Test2().Test5().foo(null)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int..kotlin.Int?!")!>Test.Test2().foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int..kotlin.Int?!")!>Test.Test2().Test5().foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)<!>
|
||||
}
|
||||
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
// MODULE: module1
|
||||
// FILE: module1/module-info.java
|
||||
import org.jspecify.nullness.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
module module1 {
|
||||
requires java9_annotations;
|
||||
exports test1;
|
||||
}
|
||||
|
||||
// FILE: module1/test1/Test.java
|
||||
package test1;
|
||||
|
||||
public class Test {
|
||||
public void foo(Integer x) {}
|
||||
}
|
||||
|
||||
// MODULE: module2(module1)
|
||||
// FILE: module2/module-info.java
|
||||
module module2 {
|
||||
requires module1;
|
||||
exports test2;
|
||||
}
|
||||
|
||||
// FILE: module2/test2/Test.java
|
||||
package test2;
|
||||
|
||||
public class Test {
|
||||
public void foo(Integer x) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(x: test1.Test, y: test2.Test) {
|
||||
x.foo(null)
|
||||
y.foo(null)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
// ALLOW_KOTLIN_PACKAGE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user