K1/K2: add a test for KT-50008
This commit is contained in:
committed by
Space Team
parent
2f056fe155
commit
d353fd400d
+35
@@ -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<T extends @Nullable Object> {
|
||||
public void foo(T t) {}
|
||||
public <E extends @Nullable Object> void bar(E e) {}
|
||||
}
|
||||
|
||||
// FILE: Test.java
|
||||
public class Test {}
|
||||
|
||||
// FILE: main.kt
|
||||
fun <T : Test> main(a1: NonPlatformTypeParameter<Any?>, a2: NonPlatformTypeParameter<Test>, x: T): Unit {
|
||||
a1.foo(null)
|
||||
a1.bar<Test?>(null)
|
||||
// jspecify_nullness_mismatch
|
||||
a1.bar<T>(<!NULL_FOR_NONNULL_TYPE!>null<!>)
|
||||
a1.bar<T>(x)
|
||||
|
||||
// jspecify_nullness_mismatch
|
||||
a2.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)
|
||||
a2.bar<Test?>(null)
|
||||
// jspecify_nullness_mismatch
|
||||
a2.bar<T>(<!NULL_FOR_NONNULL_TYPE!>null<!>)
|
||||
a2.bar<T>(x)
|
||||
}
|
||||
|
||||
fun testNullable(a1: NonPlatformTypeParameter<Test>, x: Test?) {
|
||||
// jspecify_nullness_mismatch
|
||||
a1.foo(<!ARGUMENT_TYPE_MISMATCH!>x<!>)
|
||||
}
|
||||
+6
-2
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated +TypeEnhancementImprovementsInStrictMode
|
||||
// JSPECIFY_STATE: strict
|
||||
// MUTE_FOR_PSI_CLASS_FILES_READING
|
||||
@@ -28,4 +27,9 @@ fun <T : Test> main(a1: NonPlatformTypeParameter<Any?>, a2: NonPlatformTypeParam
|
||||
// jspecify_nullness_mismatch
|
||||
a2.bar<T>(<!NULL_FOR_NONNULL_TYPE!>null<!>)
|
||||
a2.bar<T>(x)
|
||||
}
|
||||
}
|
||||
|
||||
fun testNullable(a1: NonPlatformTypeParameter<Test>, x: Test?) {
|
||||
// jspecify_nullness_mismatch
|
||||
a1.foo(<!TYPE_MISMATCH!>x<!>)
|
||||
}
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T : Test> main(/*0*/ a1: NonPlatformTypeParameter<kotlin.Any?>, /*1*/ a2: NonPlatformTypeParameter<Test>, /*2*/ x: T): kotlin.Unit
|
||||
public fun testNullable(/*0*/ a1: NonPlatformTypeParameter<Test>, /*1*/ x: Test?): kotlin.Unit
|
||||
|
||||
public open class NonPlatformTypeParameter</*0*/ T> {
|
||||
public constructor NonPlatformTypeParameter</*0*/ T>()
|
||||
|
||||
+4
@@ -25,3 +25,7 @@ fun <T : Test> main(a1: NonPlatformTypeParameter<Any?>, a2: NonPlatformTypeParam
|
||||
a2.bar<T>(null)
|
||||
a2.bar<T>(x)
|
||||
}
|
||||
|
||||
fun testNullable(a1: NonPlatformTypeParameter<Test>, x: Test?) {
|
||||
a1.foo(x)
|
||||
}
|
||||
|
||||
+6
-1
@@ -27,4 +27,9 @@ fun <T : Test> main(a1: NonPlatformTypeParameter<Any?>, a2: NonPlatformTypeParam
|
||||
// jspecify_nullness_mismatch
|
||||
a2.bar<T>(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
|
||||
a2.bar<T>(x)
|
||||
}
|
||||
}
|
||||
|
||||
fun testNullable(a1: NonPlatformTypeParameter<Test>, x: Test?) {
|
||||
// jspecify_nullness_mismatch
|
||||
a1.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>x<!>)
|
||||
}
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T : Test> main(/*0*/ a1: NonPlatformTypeParameter<kotlin.Any?>, /*1*/ a2: NonPlatformTypeParameter<Test>, /*2*/ x: T): kotlin.Unit
|
||||
public fun testNullable(/*0*/ a1: NonPlatformTypeParameter<Test>, /*1*/ x: Test?): kotlin.Unit
|
||||
|
||||
public open class NonPlatformTypeParameter</*0*/ T : @org.jspecify.annotations.Nullable kotlin.Any!> {
|
||||
public constructor NonPlatformTypeParameter</*0*/ T : @org.jspecify.annotations.Nullable kotlin.Any!>()
|
||||
|
||||
Reference in New Issue
Block a user