diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/NonPlatformTypeParameter.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/NonPlatformTypeParameter.fir.kt new file mode 100644 index 00000000000..2c0109dc50a --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/NonPlatformTypeParameter.fir.kt @@ -0,0 +1,35 @@ +// !LANGUAGE: +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated +TypeEnhancementImprovementsInStrictMode +// JSPECIFY_STATE: strict +// MUTE_FOR_PSI_CLASS_FILES_READING + +// FILE: NonPlatformTypeParameter.java +import org.jspecify.annotations.*; + +public class NonPlatformTypeParameter { + public void foo(T t) {} + public void bar(E e) {} +} + +// FILE: Test.java +public class Test {} + +// FILE: main.kt +fun main(a1: NonPlatformTypeParameter, a2: NonPlatformTypeParameter, x: T): Unit { + a1.foo(null) + a1.bar(null) + // jspecify_nullness_mismatch + a1.bar(null) + a1.bar(x) + + // jspecify_nullness_mismatch + a2.foo(null) + a2.bar(null) + // jspecify_nullness_mismatch + a2.bar(null) + a2.bar(x) +} + +fun testNullable(a1: NonPlatformTypeParameter, x: Test?) { + // jspecify_nullness_mismatch + a1.foo(x) +} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/NonPlatformTypeParameter.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/NonPlatformTypeParameter.kt index 5ce76fd29fe..d18580c6d66 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/NonPlatformTypeParameter.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/NonPlatformTypeParameter.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !LANGUAGE: +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated +TypeEnhancementImprovementsInStrictMode // JSPECIFY_STATE: strict // MUTE_FOR_PSI_CLASS_FILES_READING @@ -28,4 +27,9 @@ fun main(a1: NonPlatformTypeParameter, a2: NonPlatformTypeParam // jspecify_nullness_mismatch a2.bar(null) a2.bar(x) -} \ No newline at end of file +} + +fun testNullable(a1: NonPlatformTypeParameter, x: Test?) { + // jspecify_nullness_mismatch + a1.foo(x) +} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/NonPlatformTypeParameter.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/NonPlatformTypeParameter.txt index bd16bea0036..48a0b2b6033 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/NonPlatformTypeParameter.txt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/NonPlatformTypeParameter.txt @@ -1,6 +1,7 @@ package public fun main(/*0*/ a1: NonPlatformTypeParameter, /*1*/ a2: NonPlatformTypeParameter, /*2*/ x: T): kotlin.Unit +public fun testNullable(/*0*/ a1: NonPlatformTypeParameter, /*1*/ x: Test?): kotlin.Unit public open class NonPlatformTypeParameter { public constructor NonPlatformTypeParameter() diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/NonPlatformTypeParameter.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/NonPlatformTypeParameter.fir.kt index a04df4afb1a..339dbed47c5 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/NonPlatformTypeParameter.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/NonPlatformTypeParameter.fir.kt @@ -25,3 +25,7 @@ fun main(a1: NonPlatformTypeParameter, a2: NonPlatformTypeParam a2.bar(null) a2.bar(x) } + +fun testNullable(a1: NonPlatformTypeParameter, x: Test?) { + a1.foo(x) +} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/NonPlatformTypeParameter.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/NonPlatformTypeParameter.kt index 99f321fa9c2..ce3fee96616 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/NonPlatformTypeParameter.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/NonPlatformTypeParameter.kt @@ -27,4 +27,9 @@ fun main(a1: NonPlatformTypeParameter, a2: NonPlatformTypeParam // jspecify_nullness_mismatch a2.bar(null) a2.bar(x) -} \ No newline at end of file +} + +fun testNullable(a1: NonPlatformTypeParameter, x: Test?) { + // jspecify_nullness_mismatch + a1.foo(x) +} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/NonPlatformTypeParameter.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/NonPlatformTypeParameter.txt index 14795ddfbcc..5ffed19ebd3 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/NonPlatformTypeParameter.txt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/NonPlatformTypeParameter.txt @@ -1,6 +1,7 @@ package public fun main(/*0*/ a1: NonPlatformTypeParameter, /*1*/ a2: NonPlatformTypeParameter, /*2*/ x: T): kotlin.Unit +public fun testNullable(/*0*/ a1: NonPlatformTypeParameter, /*1*/ x: Test?): kotlin.Unit public open class NonPlatformTypeParameter { public constructor NonPlatformTypeParameter()