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,29 @@
// 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 {
a1.foo(null)
a1.foo(1)
a2.foo(null)
a2.foo(1)
a1.bar(null, null)
a1.bar(x, null)
a1.bar(x, 1)
a2.bar(null, null)
a2.bar(x, null)
a2.bar(x, 1)
}
@@ -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)
}
@@ -0,0 +1,19 @@
package
public fun main(/*0*/ a1: NullnessUnspecifiedTypeParameter<kotlin.Any>, /*1*/ a2: NullnessUnspecifiedTypeParameter<kotlin.Any?>, /*2*/ x: Test): kotlin.Unit
@org.jspecify.nullness.NullMarked public open class NullnessUnspecifiedTypeParameter</*0*/ T : kotlin.Any!> {
public constructor NullnessUnspecifiedTypeParameter</*0*/ T : kotlin.Any!>()
public open fun bar(/*0*/ s: Test!, /*1*/ t: T!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open fun foo(/*0*/ t: T!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open class Test {
public constructor Test()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}