[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.annotations.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.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
module sandbox {
|
||||
requires java9_annotations;
|
||||
exports test;
|
||||
}
|
||||
|
||||
// FILE: sandbox/test/Test.java
|
||||
package test;
|
||||
|
||||
import org.jspecify.annotations.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.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
module sandbox {
|
||||
requires java9_annotations;
|
||||
exports test;
|
||||
}
|
||||
|
||||
// FILE: sandbox/test/package-info.java
|
||||
@NullMarked
|
||||
package test;
|
||||
|
||||
import org.jspecify.annotations.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.annotations.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.annotations.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.annotations.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.annotations.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
|
||||
|
||||
|
||||
-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
|
||||
|
||||
|
||||
+9
-5
@@ -13,17 +13,21 @@ public class Test {}
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(a1: NullnessUnspecifiedTypeParameter<Any>, a2: NullnessUnspecifiedTypeParameter<Any?>, x: Test): Unit {
|
||||
a1.foo(null)
|
||||
// jspecify_nullness_mismatch
|
||||
a1.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
a1.foo(1)
|
||||
|
||||
a2.foo(null)
|
||||
a2.foo(1)
|
||||
|
||||
a1.bar(null, null)
|
||||
a1.bar(x, null)
|
||||
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
|
||||
a1.bar(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
// jspecify_nullness_mismatch
|
||||
a1.bar(x, <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
a1.bar(x, 1)
|
||||
|
||||
a2.bar(null, null)
|
||||
// jspecify_nullness_mismatch
|
||||
a2.bar(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, null)
|
||||
a2.bar(x, null)
|
||||
a2.bar(x, 1)
|
||||
}
|
||||
}
|
||||
|
||||
-80
@@ -1,80 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
// MUTE_FOR_PSI_CLASS_FILES_READING
|
||||
|
||||
// FILE: AnnotatedBoundsOfWildcard.java
|
||||
import org.jspecify.annotations.*;
|
||||
|
||||
@NullMarked
|
||||
public class AnnotatedBoundsOfWildcard {
|
||||
public void superAsIs(Test<? super Base, ? super @Nullable Base, ? super @NullnessUnspecified Base> a) {}
|
||||
public void superNotNull(Test<? super Base, ? super Base, ? super Base> a) {}
|
||||
public void superNullable(Test<? super @Nullable Base, ? super @Nullable Base, ? super @Nullable Base> a) {}
|
||||
|
||||
public void extendsAsIs(Test<? extends Base, ? extends @Nullable Base, ? extends @NullnessUnspecified Base> a) {}
|
||||
public void extendsNotNull(Test<? extends Base, ? extends Base, ? extends Base> a) {}
|
||||
public void extendsNullable(Test<? extends @Nullable Base, ? extends @Nullable Base, ? extends @Nullable Base> a) {}
|
||||
|
||||
public void noBounds(Test<? extends @NullnessUnspecified Object, ? extends @NullnessUnspecified Object, ? extends @NullnessUnspecified Object> a) {}
|
||||
}
|
||||
|
||||
// FILE: Base.java
|
||||
public class Base {}
|
||||
|
||||
// FILE: Derived.java
|
||||
public class Derived extends Base {}
|
||||
|
||||
// FILE: Test.java
|
||||
import org.jspecify.annotations.*;
|
||||
|
||||
@NullMarked
|
||||
public class Test<T extends Object, E extends @Nullable Object, F extends @NullnessUnspecified Object> { }
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(
|
||||
aNotNullNotNullNotNull: Test<Derived, Derived, Derived>,
|
||||
aNotNullNotNullNull: Test<Derived, Derived, Derived?>,
|
||||
aNotNullNullNotNull: Test<Derived, Derived?, Derived>,
|
||||
aNotNullNullNull: Test<Derived, Derived?, Derived?>,
|
||||
|
||||
aAnyNotNullNotNullNotNull: Test<Any, Any, Any>,
|
||||
aAnyNotNullNotNullNull: Test<Any, Any, Any?>,
|
||||
aAnyNotNullNullNotNull: Test<Any, Any?, Any>,
|
||||
aAnyNotNullNullNull: Test<Any, Any?, Any?>,
|
||||
|
||||
b: AnnotatedBoundsOfWildcard
|
||||
): Unit {
|
||||
b.superAsIs(aAnyNotNullNotNullNotNull)
|
||||
b.superAsIs(aAnyNotNullNotNullNull)
|
||||
b.superAsIs(aAnyNotNullNullNotNull)
|
||||
b.superAsIs(aAnyNotNullNullNull)
|
||||
|
||||
b.superNotNull(aAnyNotNullNotNullNotNull)
|
||||
b.superNotNull(aAnyNotNullNotNullNull)
|
||||
b.superNotNull(aAnyNotNullNullNotNull)
|
||||
b.superNotNull(aAnyNotNullNullNull)
|
||||
|
||||
b.superNullable(aAnyNotNullNotNullNotNull)
|
||||
b.superNullable(aAnyNotNullNotNullNull)
|
||||
b.superNullable(aAnyNotNullNullNotNull)
|
||||
b.superNullable(aAnyNotNullNullNull)
|
||||
|
||||
b.extendsAsIs(aNotNullNotNullNotNull)
|
||||
b.extendsAsIs(aNotNullNotNullNull)
|
||||
b.extendsAsIs(aNotNullNullNotNull)
|
||||
b.extendsAsIs(aNotNullNullNull)
|
||||
|
||||
b.extendsNotNull(aNotNullNotNullNotNull)
|
||||
b.extendsNotNull(aNotNullNotNullNull)
|
||||
b.extendsNotNull(aNotNullNullNotNull)
|
||||
b.extendsNotNull(aNotNullNullNull)
|
||||
|
||||
b.extendsNullable(aNotNullNotNullNotNull)
|
||||
b.extendsNullable(aNotNullNotNullNull)
|
||||
b.extendsNullable(aNotNullNullNotNull)
|
||||
b.extendsNullable(aNotNullNullNull)
|
||||
|
||||
b.noBounds(aNotNullNotNullNotNull)
|
||||
b.noBounds(aNotNullNotNullNull)
|
||||
b.noBounds(aNotNullNullNotNull)
|
||||
b.noBounds(aNotNullNullNull)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
// MUTE_FOR_PSI_CLASS_FILES_READING
|
||||
|
||||
|
||||
Vendored
-45
@@ -1,45 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
|
||||
// FILE: Defaults.java
|
||||
import org.jspecify.annotations.*;
|
||||
|
||||
@NullMarked
|
||||
public class Defaults {
|
||||
public Foo defaultField = null;
|
||||
@Nullable public Foo field = null;
|
||||
|
||||
public Foo everythingNotNullable(Foo x) { return null; }
|
||||
|
||||
public @Nullable Foo everythingNullable(@Nullable Foo x) { return null; }
|
||||
|
||||
public @NullnessUnspecified Foo everythingUnknown(@NullnessUnspecified Foo x) { return null; }
|
||||
|
||||
public @Nullable Foo mixed(Foo x) { return null; }
|
||||
|
||||
public Foo explicitlyNullnessUnspecified(@NullnessUnspecified Foo x) { return null; }
|
||||
}
|
||||
|
||||
// FILE: Foo.java
|
||||
public class Foo {
|
||||
public Object foo() { return null; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(a: Defaults, x: Foo): Unit {
|
||||
a.everythingNotNullable(null).foo()
|
||||
a.everythingNotNullable(x).foo()
|
||||
|
||||
a.everythingNullable(null).foo()
|
||||
|
||||
a.everythingUnknown(null).foo()
|
||||
|
||||
a.mixed(null).foo()
|
||||
a.mixed(x).foo()
|
||||
|
||||
a.explicitlyNullnessUnspecified(x).foo()
|
||||
a.explicitlyNullnessUnspecified(null).foo()
|
||||
|
||||
a.defaultField.foo()
|
||||
|
||||
a.field.foo()
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
|
||||
// FILE: Defaults.java
|
||||
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
|
||||
// FILE: IgnoreAnnotations.java
|
||||
import org.jspecify.annotations.*;
|
||||
|
||||
@NullMarked
|
||||
public class IgnoreAnnotations {
|
||||
@Nullable public Derived field = null;
|
||||
|
||||
@Nullable
|
||||
public Derived foo(Derived x, @NullnessUnspecified Base y) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Derived everythingNotNullable(Derived x) { return null; }
|
||||
|
||||
public @Nullable Derived everythingNullable(@Nullable Derived x) { return null; }
|
||||
|
||||
public @NullnessUnspecified Derived everythingUnknown(@NullnessUnspecified Derived x) { return null; }
|
||||
}
|
||||
|
||||
// FILE: Base.java
|
||||
public class Base {
|
||||
void foo() {}
|
||||
}
|
||||
|
||||
// FILE: Derived.java
|
||||
public class Derived extends Base { }
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(a: IgnoreAnnotations, x: Derived): Unit {
|
||||
a.foo(x, null).foo()
|
||||
a.foo(null, x).foo()
|
||||
|
||||
a.field.foo()
|
||||
|
||||
a.everythingNotNullable(null).foo()
|
||||
a.everythingNotNullable(x).foo()
|
||||
|
||||
a.everythingNullable(null).foo()
|
||||
|
||||
a.everythingUnknown(null).foo()
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
|
||||
// FILE: IgnoreAnnotations.java
|
||||
|
||||
+8
-4
@@ -14,17 +14,21 @@ public class Test {}
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(a1: NullnessUnspecifiedTypeParameter<Any>, a2: NullnessUnspecifiedTypeParameter<Any?>, x: Test): Unit {
|
||||
a1.foo(null)
|
||||
// jspecify_nullness_mismatch
|
||||
a1.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
a1.foo(1)
|
||||
|
||||
a2.foo(null)
|
||||
a2.foo(1)
|
||||
|
||||
a1.bar(null, null)
|
||||
a1.bar(x, null)
|
||||
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
|
||||
a1.bar(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
// jspecify_nullness_mismatch
|
||||
a1.bar(x, <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
a1.bar(x, 1)
|
||||
|
||||
a2.bar(null, null)
|
||||
// jspecify_nullness_mismatch
|
||||
a2.bar(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, null)
|
||||
a2.bar(x, null)
|
||||
a2.bar(x, 1)
|
||||
}
|
||||
|
||||
Vendored
-36
@@ -1,36 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
|
||||
// FILE: Simple.java
|
||||
import org.jspecify.annotations.*;
|
||||
|
||||
@NullMarked
|
||||
public class Simple {
|
||||
@Nullable public Derived field = null;
|
||||
|
||||
@Nullable
|
||||
public Derived foo(Derived x, @NullnessUnspecified Base y) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Derived bar() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Base.java
|
||||
public class Base {}
|
||||
|
||||
// FILE: Derived.java
|
||||
public class Derived extends Base {
|
||||
void foo() {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(a: Simple, x: Derived): Unit {
|
||||
a.foo(x, null).foo()
|
||||
a.foo(null, x).foo()
|
||||
|
||||
a.bar().foo()
|
||||
|
||||
a.field.foo()
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
|
||||
// FILE: Simple.java
|
||||
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
// MUTE_FOR_PSI_CLASS_FILES_READING
|
||||
|
||||
// FILE: TypeArgumentsFromParameterBounds.java
|
||||
import org.jspecify.annotations.*;
|
||||
|
||||
@NullMarked
|
||||
public class TypeArgumentsFromParameterBounds<T extends Object, E extends @Nullable Object, F extends @NullnessUnspecified Object> {}
|
||||
|
||||
// FILE: A.java
|
||||
import org.jspecify.annotations.*;
|
||||
|
||||
@NullMarked
|
||||
public class A {
|
||||
public void bar(TypeArgumentsFromParameterBounds<Test, Test, Test> a) {}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
import org.jspecify.annotations.*;
|
||||
|
||||
public class B {
|
||||
public void bar(TypeArgumentsFromParameterBounds<Test, Test, Test> a) {}
|
||||
}
|
||||
|
||||
// FILE: Test.java
|
||||
public class Test {}
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(
|
||||
aNotNullNotNullNotNull: TypeArgumentsFromParameterBounds<Test, Test, Test>,
|
||||
aNotNullNotNullNull: TypeArgumentsFromParameterBounds<Test, Test, Test?>,
|
||||
aNotNullNullNotNull: TypeArgumentsFromParameterBounds<Test, Test?, Test>,
|
||||
aNotNullNullNull: TypeArgumentsFromParameterBounds<Test, Test?, Test?>,
|
||||
a: A, b: B
|
||||
): Unit {
|
||||
a.bar(aNotNullNotNullNotNull)
|
||||
a.bar(aNotNullNotNullNull)
|
||||
a.bar(aNotNullNullNotNull)
|
||||
a.bar(aNotNullNullNull)
|
||||
|
||||
b.bar(aNotNullNotNullNotNull)
|
||||
b.bar(aNotNullNotNullNull)
|
||||
b.bar(aNotNullNullNotNull)
|
||||
b.bar(aNotNullNullNull)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
// MUTE_FOR_PSI_CLASS_FILES_READING
|
||||
|
||||
|
||||
+2
-1
@@ -33,7 +33,8 @@ fun <T : Test> main(a1: A<Any?>, a2: A<Test>, b1: B<Any?>, b2: B<Test>, x: T): U
|
||||
b1.bar<T?>(null)
|
||||
b1.bar<T>(x)
|
||||
|
||||
b2.foo(null)
|
||||
// jspecify_nullness_mismatch
|
||||
b2.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
b2.bar<T?>(null)
|
||||
b2.bar<T>(x)
|
||||
}
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
// FILE: J1.java
|
||||
import org.jspecify.annotations.*;
|
||||
|
||||
@NullMarked
|
||||
public interface J1<T extends @Nullable Object> {
|
||||
T foo();
|
||||
}
|
||||
|
||||
// FILE: J2.java
|
||||
public interface J2 {
|
||||
J1<?> bar();
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// jspecify_nullness_mismatch
|
||||
fun baz(j2: J2): Any = <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>j2.bar().foo()<!> // Any..Any?
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
// FILE: J1.java
|
||||
import org.jspecify.annotations.*;
|
||||
|
||||
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
|
||||
// FILE: Foo.java
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
public class Foo {
|
||||
public static <T> void gauge(@Nullable T stateObject) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun <T> test(metric: T) {
|
||||
if (metric is String) {
|
||||
Foo.gauge(metric)
|
||||
}
|
||||
}
|
||||
Vendored
+3
-1
@@ -1,3 +1,5 @@
|
||||
// FIR_IDENTICAL
|
||||
// DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
// JSPECIFY_STATE: warn
|
||||
|
||||
// FILE: Foo.java
|
||||
@@ -10,6 +12,6 @@ public class Foo {
|
||||
// FILE: main.kt
|
||||
fun <T> test(metric: T) {
|
||||
if (metric is String) {
|
||||
Foo.gauge(<!DEBUG_INFO_SMARTCAST!>metric<!>)
|
||||
Foo.gauge(metric)
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+5
-5
@@ -15,7 +15,7 @@ public class Test {}
|
||||
// jspecify_nullness_mismatch
|
||||
fun main(a1: NullnessUnspecifiedTypeParameter<Any>, a2: NullnessUnspecifiedTypeParameter<Any?>, x: Test): Unit {
|
||||
// jspecify_nullness_mismatch
|
||||
a1.foo(null)
|
||||
a1.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
a1.foo(1)
|
||||
|
||||
// jspecify_nullness_mismatch
|
||||
@@ -23,14 +23,14 @@ fun main(a1: NullnessUnspecifiedTypeParameter<Any>, a2: NullnessUnspecifiedTypeP
|
||||
a2.foo(1)
|
||||
|
||||
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
|
||||
a1.bar(null, null)
|
||||
a1.bar(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
// jspecify_nullness_mismatch
|
||||
a1.bar(x, null)
|
||||
a1.bar(x, <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
a1.bar(x, 1)
|
||||
|
||||
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
|
||||
a2.bar(null, null)
|
||||
a2.bar(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, null)
|
||||
// jspecify_nullness_mismatch
|
||||
a2.bar(x, null)
|
||||
a2.bar(x, 1)
|
||||
}
|
||||
}
|
||||
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
// MUTE_FOR_PSI_CLASS_FILES_READING
|
||||
|
||||
// FILE: AnnotatedBoundsOfWildcard.java
|
||||
import org.jspecify.nullness.*;
|
||||
|
||||
@NullMarked
|
||||
public class AnnotatedBoundsOfWildcard {
|
||||
public void superAsIs(Test<? super Base, ? super @Nullable Base, ? super @NullnessUnspecified Base> a) {}
|
||||
public void superNotNull(Test<? super Base, ? super Base, ? super Base> a) {}
|
||||
public void superNullable(Test<? super @Nullable Base, ? super @Nullable Base, ? super @Nullable Base> a) {}
|
||||
|
||||
public void extendsAsIs(Test<? extends Base, ? extends @Nullable Base, ? extends @NullnessUnspecified Base> a) {}
|
||||
public void extendsNotNull(Test<? extends Base, ? extends Base, ? extends Base> a) {}
|
||||
public void extendsNullable(Test<? extends @Nullable Base, ? extends @Nullable Base, ? extends @Nullable Base> a) {}
|
||||
|
||||
public void noBounds(Test<? extends @NullnessUnspecified Object, ? extends @NullnessUnspecified Object, ? extends @NullnessUnspecified Object> a) {}
|
||||
}
|
||||
|
||||
// FILE: Base.java
|
||||
public class Base {}
|
||||
|
||||
// FILE: Derived.java
|
||||
public class Derived extends Base {}
|
||||
|
||||
// FILE: Test.java
|
||||
import org.jspecify.nullness.*;
|
||||
|
||||
@NullMarked
|
||||
public class Test<T extends Object, E extends @Nullable Object, F extends @NullnessUnspecified Object> { }
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(
|
||||
aNotNullNotNullNotNull: Test<Derived, Derived, Derived>,
|
||||
aNotNullNotNullNull: Test<Derived, Derived, Derived?>,
|
||||
aNotNullNullNotNull: Test<Derived, Derived?, Derived>,
|
||||
aNotNullNullNull: Test<Derived, Derived?, Derived?>,
|
||||
|
||||
aAnyNotNullNotNullNotNull: Test<Any, Any, Any>,
|
||||
aAnyNotNullNotNullNull: Test<Any, Any, Any?>,
|
||||
aAnyNotNullNullNotNull: Test<Any, Any?, Any>,
|
||||
aAnyNotNullNullNull: Test<Any, Any?, Any?>,
|
||||
|
||||
b: AnnotatedBoundsOfWildcard
|
||||
): Unit {
|
||||
// jspecify_nullness_mismatch
|
||||
b.superAsIs(aAnyNotNullNotNullNotNull)
|
||||
// jspecify_nullness_mismatch
|
||||
b.superAsIs(aAnyNotNullNotNullNull)
|
||||
b.superAsIs(aAnyNotNullNullNotNull)
|
||||
b.superAsIs(aAnyNotNullNullNull)
|
||||
|
||||
b.superNotNull(aAnyNotNullNotNullNotNull)
|
||||
b.superNotNull(aAnyNotNullNotNullNull)
|
||||
b.superNotNull(aAnyNotNullNullNotNull)
|
||||
b.superNotNull(aAnyNotNullNullNull)
|
||||
|
||||
// jspecify_nullness_mismatch
|
||||
b.superNullable(aAnyNotNullNotNullNotNull)
|
||||
// jspecify_nullness_mismatch
|
||||
b.superNullable(aAnyNotNullNotNullNull)
|
||||
// jspecify_nullness_mismatch
|
||||
b.superNullable(aAnyNotNullNullNotNull)
|
||||
// jspecify_nullness_mismatch
|
||||
b.superNullable(aAnyNotNullNullNull)
|
||||
|
||||
b.extendsAsIs(aNotNullNotNullNotNull)
|
||||
b.extendsAsIs(aNotNullNotNullNull)
|
||||
b.extendsAsIs(aNotNullNullNotNull)
|
||||
b.extendsAsIs(aNotNullNullNull)
|
||||
|
||||
b.extendsNotNull(aNotNullNotNullNotNull)
|
||||
// jspecify_nullness_mismatch
|
||||
b.extendsNotNull(aNotNullNotNullNull)
|
||||
// jspecify_nullness_mismatch
|
||||
b.extendsNotNull(aNotNullNullNotNull)
|
||||
// jspecify_nullness_mismatch
|
||||
b.extendsNotNull(aNotNullNullNull)
|
||||
|
||||
b.extendsNullable(aNotNullNotNullNotNull)
|
||||
b.extendsNullable(aNotNullNotNullNull)
|
||||
b.extendsNullable(aNotNullNullNotNull)
|
||||
b.extendsNullable(aNotNullNullNull)
|
||||
|
||||
b.noBounds(aNotNullNotNullNotNull)
|
||||
b.noBounds(aNotNullNotNullNull)
|
||||
b.noBounds(aNotNullNullNotNull)
|
||||
b.noBounds(aNotNullNullNull)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
// MUTE_FOR_PSI_CLASS_FILES_READING
|
||||
|
||||
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
|
||||
// FILE: Defaults.java
|
||||
import org.jspecify.nullness.*;
|
||||
|
||||
@NullMarked
|
||||
public class Defaults {
|
||||
public Foo defaultField = null;
|
||||
@Nullable public Foo field = null;
|
||||
|
||||
public Foo everythingNotNullable(Foo x) { return null; }
|
||||
|
||||
public @Nullable Foo everythingNullable(@Nullable Foo x) { return null; }
|
||||
|
||||
public @NullnessUnspecified Foo everythingUnknown(@NullnessUnspecified Foo x) { return null; }
|
||||
|
||||
public @Nullable Foo mixed(Foo x) { return null; }
|
||||
|
||||
public Foo explicitlyNullnessUnspecified(@NullnessUnspecified Foo x) { return null; }
|
||||
}
|
||||
|
||||
// FILE: Foo.java
|
||||
public class Foo {
|
||||
public Object foo() { return null; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(a: Defaults, x: Foo): Unit {
|
||||
// jspecify_nullness_mismatch
|
||||
a.everythingNotNullable(null).foo()
|
||||
a.everythingNotNullable(x).foo()
|
||||
|
||||
// jspecify_nullness_mismatch
|
||||
a.everythingNullable(null).foo()
|
||||
|
||||
a.everythingUnknown(null).foo()
|
||||
|
||||
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
|
||||
a.mixed(null).foo()
|
||||
// jspecify_nullness_mismatch
|
||||
a.mixed(x).foo()
|
||||
|
||||
a.explicitlyNullnessUnspecified(x).foo()
|
||||
a.explicitlyNullnessUnspecified(null).foo()
|
||||
|
||||
a.defaultField.foo()
|
||||
|
||||
// jspecify_nullness_mismatch
|
||||
a.field.foo()
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
|
||||
// FILE: Defaults.java
|
||||
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
|
||||
// FILE: IgnoreAnnotations.java
|
||||
import org.jspecify.nullness.*;
|
||||
|
||||
@NullMarked
|
||||
public class IgnoreAnnotations {
|
||||
@Nullable public Derived field = null;
|
||||
|
||||
@Nullable
|
||||
public Derived foo(Derived x, @NullnessUnspecified Base y) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Derived everythingNotNullable(Derived x) { return null; }
|
||||
|
||||
public @Nullable Derived everythingNullable(@Nullable Derived x) { return null; }
|
||||
|
||||
public @NullnessUnspecified Derived everythingUnknown(@NullnessUnspecified Derived x) { return null; }
|
||||
}
|
||||
|
||||
// FILE: Base.java
|
||||
public class Base {
|
||||
void foo() {}
|
||||
}
|
||||
|
||||
// FILE: Derived.java
|
||||
public class Derived extends Base { }
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(a: IgnoreAnnotations, x: Derived): Unit {
|
||||
// jspecify_nullness_mismatch
|
||||
a.foo(x, null).foo()
|
||||
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
|
||||
a.foo(null, x).foo()
|
||||
|
||||
// jspecify_nullness_mismatch
|
||||
a.field.foo()
|
||||
|
||||
// jspecify_nullness_mismatch
|
||||
a.everythingNotNullable(null).foo()
|
||||
a.everythingNotNullable(x).foo()
|
||||
|
||||
// jspecify_nullness_mismatch
|
||||
a.everythingNullable(null).foo()
|
||||
|
||||
a.everythingUnknown(null).foo()
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
|
||||
// FILE: IgnoreAnnotations.java
|
||||
|
||||
+4
-4
@@ -16,7 +16,7 @@ public class Test {}
|
||||
// jspecify_nullness_mismatch
|
||||
fun main(a1: NullnessUnspecifiedTypeParameter<Any>, a2: NullnessUnspecifiedTypeParameter<Any?>, x: Test): Unit {
|
||||
// jspecify_nullness_mismatch
|
||||
a1.foo(null)
|
||||
a1.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
a1.foo(1)
|
||||
|
||||
// jspecify_nullness_mismatch
|
||||
@@ -24,13 +24,13 @@ fun main(a1: NullnessUnspecifiedTypeParameter<Any>, a2: NullnessUnspecifiedTypeP
|
||||
a2.foo(1)
|
||||
|
||||
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
|
||||
a1.bar(null, null)
|
||||
a1.bar(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
// jspecify_nullness_mismatch
|
||||
a1.bar(x, null)
|
||||
a1.bar(x, <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
a1.bar(x, 1)
|
||||
|
||||
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
|
||||
a2.bar(null, null)
|
||||
a2.bar(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, null)
|
||||
// jspecify_nullness_mismatch
|
||||
a2.bar(x, null)
|
||||
a2.bar(x, 1)
|
||||
|
||||
Vendored
-39
@@ -1,39 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
|
||||
// FILE: Simple.java
|
||||
import org.jspecify.nullness.*;
|
||||
|
||||
@NullMarked
|
||||
public class Simple {
|
||||
@Nullable public Derived field = null;
|
||||
|
||||
@Nullable
|
||||
public Derived foo(Derived x, @NullnessUnspecified Base y) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Derived bar() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Base.java
|
||||
public class Base {}
|
||||
|
||||
// FILE: Derived.java
|
||||
public class Derived extends Base {
|
||||
void foo() {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(a: Simple, x: Derived): Unit {
|
||||
// jspecify_nullness_mismatch
|
||||
a.foo(x, null).foo()
|
||||
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
|
||||
a.foo(null, x).foo()
|
||||
|
||||
a.bar().foo()
|
||||
|
||||
// jspecify_nullness_mismatch
|
||||
a.field.foo()
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
|
||||
// FILE: Simple.java
|
||||
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
// MUTE_FOR_PSI_CLASS_FILES_READING
|
||||
|
||||
// FILE: TypeArgumentsFromParameterBounds.java
|
||||
import org.jspecify.nullness.*;
|
||||
|
||||
@NullMarked
|
||||
public class TypeArgumentsFromParameterBounds<T extends Object, E extends @Nullable Object, F extends @NullnessUnspecified Object> {}
|
||||
|
||||
// FILE: A.java
|
||||
import org.jspecify.nullness.*;
|
||||
|
||||
@NullMarked
|
||||
public class A {
|
||||
public void bar(TypeArgumentsFromParameterBounds<Test, Test, Test> a) {}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
import org.jspecify.nullness.*;
|
||||
|
||||
public class B {
|
||||
public void bar(TypeArgumentsFromParameterBounds<Test, Test, Test> a) {}
|
||||
}
|
||||
|
||||
// FILE: Test.java
|
||||
public class Test {}
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(
|
||||
aNotNullNotNullNotNull: TypeArgumentsFromParameterBounds<Test, Test, Test>,
|
||||
aNotNullNotNullNull: TypeArgumentsFromParameterBounds<Test, Test, Test?>,
|
||||
aNotNullNullNotNull: TypeArgumentsFromParameterBounds<Test, Test?, Test>,
|
||||
aNotNullNullNull: TypeArgumentsFromParameterBounds<Test, Test?, Test?>,
|
||||
a: A, b: B
|
||||
): Unit {
|
||||
a.bar(aNotNullNotNullNotNull)
|
||||
// jspecify_nullness_mismatch
|
||||
a.bar(aNotNullNotNullNull)
|
||||
// jspecify_nullness_mismatch
|
||||
a.bar(aNotNullNullNotNull)
|
||||
// jspecify_nullness_mismatch
|
||||
a.bar(aNotNullNullNull)
|
||||
|
||||
b.bar(aNotNullNotNullNotNull)
|
||||
b.bar(aNotNullNotNullNull)
|
||||
b.bar(aNotNullNullNotNull)
|
||||
b.bar(aNotNullNullNull)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
// MUTE_FOR_PSI_CLASS_FILES_READING
|
||||
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ fun <T : Test> main(a1: A<Any?>, a2: A<Test>, b1: B<Any?>, b2: B<Test>, x: T): U
|
||||
b1.bar<T>(x)
|
||||
|
||||
// jspecify_nullness_mismatch
|
||||
b2.foo(null)
|
||||
b2.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
// jspecify_nullness_mismatch
|
||||
b2.bar<T?>(null)
|
||||
b2.bar<T>(x)
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
// FILE: J1.java
|
||||
import org.jspecify.nullness.*;
|
||||
|
||||
@NullMarked
|
||||
public interface J1<T extends @Nullable Object> {
|
||||
T foo();
|
||||
}
|
||||
|
||||
// FILE: J2.java
|
||||
public interface J2 {
|
||||
J1<?> bar();
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun baz(j2: J2): Any = <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>j2.bar().foo()<!> // Any..Any?
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSPECIFY_STATE: warn
|
||||
// FILE: J1.java
|
||||
import org.jspecify.nullness.*;
|
||||
|
||||
+6
-6
@@ -26,21 +26,21 @@ public class A<T> {
|
||||
// FILE: main.kt
|
||||
fun main(a: A<String>, a1: A<String?>) {
|
||||
a.foo("", null)?.length
|
||||
a.foo("", null).length
|
||||
a.foo(null, "").length
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.foo("", null)<!>.length
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, "")<!>.length
|
||||
|
||||
a.bar().length
|
||||
a.bar()!!.length
|
||||
|
||||
a.field?.length
|
||||
a.field.length
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.field<!>.length
|
||||
|
||||
a.baz("").length
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.baz("")<!>.length
|
||||
a.baz("")?.length
|
||||
a.baz(null).length
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.baz(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)<!>.length
|
||||
|
||||
a1.baz("")!!.length
|
||||
a1.baz(null)!!.length
|
||||
a1.baz(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)!!.length
|
||||
|
||||
a.baz2("").length
|
||||
a.baz2("")?.length
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ public class ClassWithExternalAnnotatedMembers {
|
||||
// FILE: usage.kt
|
||||
fun test() {
|
||||
val i: Int? = null
|
||||
ClassWithExternalAnnotatedMembers(i)
|
||||
ClassWithExternalAnnotatedMembers(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>i<!>)
|
||||
|
||||
val s: String? = null
|
||||
<!NONE_APPLICABLE!>ClassWithExternalAnnotatedMembers<!>(s)
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ public class ClassWithExternalAnnotatedMembers {
|
||||
// FILE: usage.kt
|
||||
fun test() {
|
||||
val i: Int? = null
|
||||
ClassWithExternalAnnotatedMembers(i)
|
||||
ClassWithExternalAnnotatedMembers(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>i<!>)
|
||||
|
||||
val s: String? = null
|
||||
<!NONE_APPLICABLE!>ClassWithExternalAnnotatedMembers<!>(s)
|
||||
@@ -22,7 +22,7 @@ fun test() {
|
||||
val b: Boolean? = null
|
||||
<!NONE_APPLICABLE!>ClassWithExternalAnnotatedMembers<!>(b)
|
||||
|
||||
ClassWithExternalAnnotatedMembers(null)
|
||||
ClassWithExternalAnnotatedMembers(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
}
|
||||
|
||||
// FILE: annotations.xml
|
||||
|
||||
+2
-2
@@ -16,12 +16,12 @@ fun test() {
|
||||
instance.<!NONE_APPLICABLE!>method<!>(i)
|
||||
|
||||
val s: String? = null
|
||||
instance.method(s)
|
||||
instance.method(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>s<!>)
|
||||
|
||||
val b: Boolean? = null
|
||||
instance.<!NONE_APPLICABLE!>method<!>(b)
|
||||
|
||||
instance.method(null)
|
||||
instance.method(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
}
|
||||
|
||||
// FILE: annotations.xml
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ fun test() {
|
||||
instance.<!NONE_APPLICABLE!>method<!>(i)
|
||||
|
||||
val s: String? = null
|
||||
instance.method(s)
|
||||
instance.method(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>s<!>)
|
||||
|
||||
val b: Boolean? = null
|
||||
instance.method(b)
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
public static @MyNullable String bar() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun foo1(): String = <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>A.bar()<!>
|
||||
fun foo2(): String? = A.bar()
|
||||
fun foo3() = A.bar()
|
||||
+12
-12
@@ -10,40 +10,40 @@ public class J {
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
fun test() {
|
||||
var platformNN = J.staticNN
|
||||
var platformN = J.staticN
|
||||
var platformJ = J.staticJ
|
||||
var platformNN = J.staticNN
|
||||
var platformN = J.staticN
|
||||
var platformJ = J.staticJ
|
||||
|
||||
fun test() {
|
||||
+platformNN
|
||||
+platformN
|
||||
+<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN<!>
|
||||
+platformJ
|
||||
|
||||
++platformNN
|
||||
++platformN
|
||||
++<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN<!>
|
||||
++platformJ
|
||||
|
||||
platformNN++
|
||||
platformN++
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN++<!>
|
||||
platformJ++
|
||||
|
||||
1 + platformNN
|
||||
1 + platformN
|
||||
1 + <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN<!>
|
||||
1 + platformJ
|
||||
|
||||
platformNN + 1
|
||||
platformN + 1
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN<!> + 1
|
||||
platformJ + 1
|
||||
|
||||
1 <!INFIX_MODIFIER_REQUIRED!>plus<!> platformNN
|
||||
1 <!INFIX_MODIFIER_REQUIRED!>plus<!> platformN
|
||||
1 <!INFIX_MODIFIER_REQUIRED!>plus<!> <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN<!>
|
||||
1 <!INFIX_MODIFIER_REQUIRED!>plus<!> platformJ
|
||||
|
||||
platformNN <!INFIX_MODIFIER_REQUIRED!>plus<!> 1
|
||||
platformN <!INFIX_MODIFIER_REQUIRED!>plus<!> 1
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN<!> <!INFIX_MODIFIER_REQUIRED!>plus<!> 1
|
||||
platformJ <!INFIX_MODIFIER_REQUIRED!>plus<!> 1
|
||||
|
||||
platformNN += 1
|
||||
platformN += 1
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN<!> += 1
|
||||
platformJ += 1
|
||||
}
|
||||
|
||||
+4
-4
@@ -10,11 +10,11 @@ public class J {
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
fun test() {
|
||||
var platformNN = J.staticNN
|
||||
var platformN = J.staticN
|
||||
var platformJ = J.staticJ
|
||||
var platformNN = J.staticNN
|
||||
var platformN = J.staticN
|
||||
var platformJ = J.staticJ
|
||||
|
||||
fun test() {
|
||||
+platformNN
|
||||
+<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN<!>
|
||||
+platformJ
|
||||
|
||||
+3
@@ -1,5 +1,8 @@
|
||||
package
|
||||
|
||||
public var platformJ: kotlin.Int!
|
||||
public var platformN: kotlin.Int!
|
||||
public var platformNN: kotlin.Int!
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public open class J {
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
@MyNonnull
|
||||
public static Integer[] staticNN;
|
||||
@MyNullable
|
||||
public static Integer[] staticN;
|
||||
public static Integer[] staticJ;
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
fun test() {
|
||||
val platformNN = J.staticNN
|
||||
val platformN = J.staticN
|
||||
val platformJ = J.staticJ
|
||||
|
||||
platformNN[0]
|
||||
platformN[0]
|
||||
platformJ[0]
|
||||
|
||||
platformNN[0] = 1
|
||||
platformN[0] = 1
|
||||
platformJ[0] = 1
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
@MyNonnull
|
||||
public static J staticNN;
|
||||
@MyNullable
|
||||
public static J staticN;
|
||||
public static J staticJ;
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
var v: J = J()
|
||||
var n: J? = J()
|
||||
|
||||
fun test() {
|
||||
v = J.staticNN
|
||||
v = J.staticN
|
||||
v = J.staticJ
|
||||
|
||||
n = J.staticNN
|
||||
n = J.staticN
|
||||
n = J.staticJ
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
|
||||
+6
-6
@@ -17,26 +17,26 @@ fun test() {
|
||||
val platformJ = J.staticJ
|
||||
|
||||
if (platformNN) {}
|
||||
if (platformN) {}
|
||||
if (<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN<!>) {}
|
||||
if (platformJ) {}
|
||||
|
||||
while (platformNN) {}
|
||||
while (platformN) {}
|
||||
while (<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN<!>) {}
|
||||
while (platformJ) {}
|
||||
|
||||
do {} while (platformNN)
|
||||
do {} while (platformN)
|
||||
do {} while (<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN<!>)
|
||||
do {} while (platformJ)
|
||||
|
||||
platformNN && false
|
||||
platformN && false
|
||||
<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN<!> && false
|
||||
platformJ && false
|
||||
|
||||
platformNN || false
|
||||
platformN || false
|
||||
<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN<!> || false
|
||||
platformJ || false
|
||||
|
||||
!platformNN
|
||||
!platformN
|
||||
!<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN<!>
|
||||
!platformJ
|
||||
}
|
||||
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
@MyNonnull
|
||||
public static J staticNN;
|
||||
@MyNullable
|
||||
public static J staticN;
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
fun test() {
|
||||
val n = J.staticN
|
||||
foo(n)
|
||||
J.staticNN = n
|
||||
if (n != null) {
|
||||
foo(n)
|
||||
J.staticNN = n
|
||||
}
|
||||
|
||||
val x: J? = null
|
||||
J.staticNN = x
|
||||
if (x != null) {
|
||||
J.staticNN = x
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(j: J) {}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
@MyNonnull
|
||||
public static J staticNN;
|
||||
@MyNullable
|
||||
public static J staticN;
|
||||
public static J staticJ;
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
fun test() {
|
||||
val platformNN = J.staticNN
|
||||
val platformN = J.staticN
|
||||
val platformJ = J.staticJ
|
||||
|
||||
fun foo(p: J = platformNN, p1: J = platformN, p2: J = platformJ) {}
|
||||
|
||||
fun foo1(p: J? = platformNN, p1: J? = platformN, p2: J? = platformJ) {}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
|
||||
public interface DP {
|
||||
String getValue(Object a, Object b);
|
||||
String setValue(Object a, Object b, Object c);
|
||||
}
|
||||
|
||||
@MyNonnull
|
||||
public static DP staticNN;
|
||||
@MyNullable
|
||||
public static DP staticN;
|
||||
public static DP staticJ;
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
var A by J.staticNN
|
||||
var B by J.staticN
|
||||
var C by J.staticJ
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
|
||||
+2
-2
@@ -17,14 +17,14 @@ fun test() {
|
||||
val platformJ = J.staticJ
|
||||
|
||||
platformNN.foo()
|
||||
platformN.foo()
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN<!>.foo()
|
||||
platformJ.foo()
|
||||
|
||||
with(platformNN) {
|
||||
foo()
|
||||
}
|
||||
with(platformN) {
|
||||
foo()
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>foo()<!>
|
||||
}
|
||||
with(platformJ) {
|
||||
foo()
|
||||
|
||||
+2
-2
@@ -22,14 +22,14 @@ fun test() {
|
||||
val platformJ = J.staticJ
|
||||
|
||||
platformNN.foo()
|
||||
platformN.foo()
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>platformN<!>.foo()
|
||||
platformJ.foo()
|
||||
|
||||
with(platformNN) {
|
||||
foo()
|
||||
}
|
||||
with(platformN) {
|
||||
foo()
|
||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>foo()<!>
|
||||
}
|
||||
with(platformJ) {
|
||||
foo()
|
||||
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
@MyNonnull
|
||||
public static J staticNN;
|
||||
@MyNullable
|
||||
public static J staticN;
|
||||
public static J staticJ;
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
fun test() {
|
||||
val platformNN = J.staticNN
|
||||
val platformN = J.staticN
|
||||
val platformJ = J.staticJ
|
||||
|
||||
checkSubtype<J>(platformNN)
|
||||
checkSubtype<J>(platformN)
|
||||
checkSubtype<J>(platformJ)
|
||||
|
||||
checkSubtype<J?>(platformNN)
|
||||
checkSubtype<J?>(platformN)
|
||||
checkSubtype<J?>(platformJ)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
import java.util.*;
|
||||
|
||||
public class J {
|
||||
@MyNonnull
|
||||
public static List<String> staticNN;
|
||||
@MyNullable
|
||||
public static List<String> staticN;
|
||||
public static List<String> staticJ;
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
fun test() {
|
||||
val platformNN = J.staticNN
|
||||
val platformN = J.staticN
|
||||
val platformJ = J.staticJ
|
||||
|
||||
for (x in platformNN) {}
|
||||
for (x in platformN) {}
|
||||
for (x in platformJ) {}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
|
||||
+12
-1
@@ -1,4 +1,5 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// LANGUAGE: +ContextReceivers
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
@@ -13,13 +14,23 @@ public class J {
|
||||
// FILE: k.kt
|
||||
fun test() {
|
||||
foo(J.staticNN)
|
||||
foo(J.staticN)
|
||||
foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>J.staticN<!>)
|
||||
foo(J.staticJ)
|
||||
|
||||
bar(J.staticNN)
|
||||
bar(J.staticN)
|
||||
bar(J.staticJ)
|
||||
|
||||
with(J.staticNN) { baz() }
|
||||
with(J.staticN) { <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>baz()<!> }
|
||||
with(J.staticJ) { baz() }
|
||||
|
||||
with(J.staticNN) { qux() }
|
||||
with(J.staticN) { qux() }
|
||||
with(J.staticJ) { qux() }
|
||||
}
|
||||
|
||||
fun foo(j: J) {}
|
||||
fun bar(j: J?) {}
|
||||
context(J) fun baz() {}
|
||||
context(J?) fun qux() {}
|
||||
|
||||
+11
@@ -1,4 +1,5 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// LANGUAGE: +ContextReceivers
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
@@ -19,7 +20,17 @@ fun test() {
|
||||
bar(J.staticNN)
|
||||
bar(J.staticN)
|
||||
bar(J.staticJ)
|
||||
|
||||
with(J.staticNN) { baz() }
|
||||
with(J.staticN) { baz() }
|
||||
with(J.staticJ) { baz() }
|
||||
|
||||
with(J.staticNN) { qux() }
|
||||
with(J.staticN) { qux() }
|
||||
with(J.staticJ) { qux() }
|
||||
}
|
||||
|
||||
fun foo(j: J) {}
|
||||
fun bar(j: J?) {}
|
||||
context(J) fun baz() {}
|
||||
context(J?) fun qux() {}
|
||||
+2
@@ -1,7 +1,9 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ j: J?): kotlin.Unit
|
||||
context(J) public fun baz(): kotlin.Unit
|
||||
public fun foo(/*0*/ j: J): kotlin.Unit
|
||||
context(J?) public fun qux(): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public open class J {
|
||||
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public interface Invoke {
|
||||
void invoke();
|
||||
}
|
||||
|
||||
@MyNonnull
|
||||
public static Invoke staticNN;
|
||||
@MyNullable
|
||||
public static Invoke staticN;
|
||||
public static Invoke staticJ;
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
fun test() {
|
||||
J.staticNN()
|
||||
J.staticN()
|
||||
J.staticJ()
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// KT-6829 False warning on map to @Nullable
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
|
||||
@MyNullable
|
||||
public String method() { return ""; }
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
fun foo(collection: Collection<J>) {
|
||||
val mapped = collection.map { it.method() }
|
||||
mapped[0].length
|
||||
}
|
||||
|
||||
public fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> {
|
||||
null!!
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
|
||||
+1
-1
@@ -22,6 +22,6 @@ fun test() {
|
||||
val platformJ = J.staticJ
|
||||
|
||||
val (a1, b1) = platformNN
|
||||
val (a2, b2) = platformN
|
||||
val (<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a2<!>, <!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>b2<!>) = platformN
|
||||
val (a3, b3) = platformJ
|
||||
}
|
||||
|
||||
-88
@@ -1,88 +0,0 @@
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
@MyNonnull
|
||||
public static J staticNN;
|
||||
@MyNullable
|
||||
public static J staticN;
|
||||
public static J staticJ;
|
||||
|
||||
public static void staticSet(@MyNonnull J nn, @MyNullable J n, J j) {}
|
||||
|
||||
public J(@MyNonnull J nn, @MyNullable J n, J j) {}
|
||||
public J() {}
|
||||
|
||||
@MyNonnull
|
||||
public J nn;
|
||||
@MyNullable
|
||||
public J n;
|
||||
public J j;
|
||||
|
||||
public void set(@MyNonnull J nn, @MyNullable J n, J j) {}
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
fun test(n: J?, nn: J) {
|
||||
// @NotNull platform type
|
||||
val platformNN = J.staticNN
|
||||
// @Nullable platform type
|
||||
val platformN = J.staticN
|
||||
// platform type with no annotation
|
||||
val platformJ = J.staticJ
|
||||
|
||||
J.staticNN = n
|
||||
J.staticNN = platformN
|
||||
J.staticNN = nn
|
||||
J.staticNN = platformNN
|
||||
J.staticNN = platformJ
|
||||
|
||||
J.staticN = n
|
||||
J.staticN = platformN
|
||||
J.staticN = nn
|
||||
J.staticN = platformNN
|
||||
J.staticN = platformJ
|
||||
|
||||
J.staticJ = n
|
||||
J.staticJ = platformN
|
||||
J.staticJ = nn
|
||||
J.staticJ = platformNN
|
||||
J.staticJ = platformJ
|
||||
|
||||
J.staticSet(nn, nn, nn)
|
||||
J.staticSet(platformNN, platformNN, platformNN)
|
||||
J.staticSet(n, n, n)
|
||||
J.staticSet(platformN, platformN, platformN)
|
||||
J.staticSet(platformJ, platformJ, platformJ)
|
||||
|
||||
J().nn = n
|
||||
J().nn = platformN
|
||||
J().nn = nn
|
||||
J().nn = platformNN
|
||||
J().nn = platformJ
|
||||
|
||||
J().n = n
|
||||
J().n = platformN
|
||||
J().n = nn
|
||||
J().n = platformNN
|
||||
J().n = platformJ
|
||||
|
||||
J().j = n
|
||||
J().j = platformN
|
||||
J().j = nn
|
||||
J().j = platformNN
|
||||
J().j = platformJ
|
||||
|
||||
J().set(nn, nn, nn)
|
||||
J().set(platformNN, platformNN, platformNN)
|
||||
J().set(n, n, n)
|
||||
J().set(platformN, platformN, platformN)
|
||||
J().set(platformJ, platformJ, platformJ)
|
||||
|
||||
J(nn, nn, nn)
|
||||
J(platformNN, platformNN, platformNN)
|
||||
J(n, n, n)
|
||||
J(platformN, platformN, platformN)
|
||||
J(platformJ, platformJ, platformJ)
|
||||
}
|
||||
+23
@@ -1,3 +1,5 @@
|
||||
// FIR_IDENTICAL
|
||||
// WITH_STDLIB
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
@@ -37,18 +39,39 @@ fun test(n: J?, nn: J) {
|
||||
J.staticNN = nn
|
||||
J.staticNN = platformNN
|
||||
J.staticNN = platformJ
|
||||
J.staticNN = <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>
|
||||
J.staticNN = requireNotNull(J.staticNN)
|
||||
J.staticNN = requireNotNull(J.staticN)
|
||||
J.staticNN = requireNotNull(J.staticJ)
|
||||
J.staticNN = J.staticNN as J
|
||||
J.staticNN = J.staticN as J
|
||||
J.staticNN = J.staticJ as J
|
||||
|
||||
J.staticN = n
|
||||
J.staticN = platformN
|
||||
J.staticN = nn
|
||||
J.staticN = platformNN
|
||||
J.staticN = platformJ
|
||||
J.staticN = null
|
||||
J.staticN = requireNotNull(J.staticNN)
|
||||
J.staticN = requireNotNull(J.staticN)
|
||||
J.staticN = requireNotNull(J.staticJ)
|
||||
J.staticN = J.staticNN as J
|
||||
J.staticN = J.staticN as J
|
||||
J.staticN = J.staticJ as J
|
||||
|
||||
J.staticJ = n
|
||||
J.staticJ = platformN
|
||||
J.staticJ = nn
|
||||
J.staticJ = platformNN
|
||||
J.staticJ = platformJ
|
||||
J.staticJ = null
|
||||
J.staticJ = requireNotNull(J.staticNN)
|
||||
J.staticJ = requireNotNull(J.staticN)
|
||||
J.staticJ = requireNotNull(J.staticJ)
|
||||
J.staticJ = J.staticNN as J
|
||||
J.staticJ = J.staticN as J
|
||||
J.staticJ = J.staticJ as J
|
||||
|
||||
J.staticSet(nn, nn, nn)
|
||||
J.staticSet(platformNN, platformNN, platformNN)
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
@MyNonnull
|
||||
public static int[] staticNN;
|
||||
@MyNullable
|
||||
public static int[] staticN;
|
||||
public static int[] staticJ;
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
fun test() {
|
||||
val platformNN = J.staticNN
|
||||
val platformN = J.staticN
|
||||
val platformJ = J.staticJ
|
||||
|
||||
platformNN[0]
|
||||
platformN[0]
|
||||
platformJ[0]
|
||||
|
||||
platformNN[0] = 1
|
||||
platformN[0] = 1
|
||||
platformJ[0] = 1
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// JSR305_GLOBAL_REPORT: warn
|
||||
|
||||
// FILE: J.java
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user