Use warn mode by default for jspecify nullability annotations in 1.6

^KT-48851 Fixed
This commit is contained in:
Victor Petukhov
2021-09-21 16:37:40 +03:00
parent 013139f18e
commit 70d70b9042
13 changed files with 131 additions and 6 deletions
@@ -0,0 +1,35 @@
// FILE: NullnessUnspecifiedTypeParameter.java
import org.jspecify.nullness.*;
@NullMarked
public class NullnessUnspecifiedTypeParameter<T> {
public void foo(T t) {}
public void bar(Test s, T t) {} // t should not become not nullable
}
// FILE: Test.java
public class Test {}
// FILE: main.kt
fun main(a1: NullnessUnspecifiedTypeParameter<Any>, a2: NullnessUnspecifiedTypeParameter<Any?>, x: Test): Unit {
// jspecify_nullness_mismatch
a1.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
a1.foo(1)
// jspecify_nullness_mismatch
a2.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
a2.foo(1)
// 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)
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
a2.bar(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
// jspecify_nullness_mismatch
a2.bar(x, <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
a2.bar(x, 1)
}