Do preparation of enhancement as well (for types with enhancement), during subtype checks
^KT-47899 Fixed
This commit is contained in:
committed by
teamcityserver
parent
c5d783596d
commit
5684b6977a
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// JSPECIFY_STATE: warn
|
||||
|
||||
// FILE: Foo.java
|
||||
import org.jspecify.nullness.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(<!DEBUG_INFO_SMARTCAST!>metric<!>)
|
||||
}
|
||||
}
|
||||
+6
@@ -808,6 +808,12 @@ public class ForeignAnnotationsCompiledJavaTestGenerated extends AbstractForeign
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/IgnoreAnnotations.fir.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47899.kt")
|
||||
public void testKt47899() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NonPlatformTypeParameter.kt")
|
||||
public void testNonPlatformTypeParameter() throws Exception {
|
||||
|
||||
+6
@@ -808,6 +808,12 @@ public class ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated exte
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/IgnoreAnnotations.fir.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47899.kt")
|
||||
public void testKt47899() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NonPlatformTypeParameter.kt")
|
||||
public void testNonPlatformTypeParameter() throws Exception {
|
||||
|
||||
+6
@@ -808,6 +808,12 @@ public class ForeignAnnotationsSourceJavaTestGenerated extends AbstractForeignAn
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/IgnoreAnnotations.fir.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47899.kt")
|
||||
public void testKt47899() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NonPlatformTypeParameter.kt")
|
||||
public void testNonPlatformTypeParameter() throws Exception {
|
||||
|
||||
@@ -144,6 +144,9 @@ fun KotlinType.unwrapEnhancementDeeply() = getEnhancementDeeply() ?: this
|
||||
|
||||
fun KotlinType.unwrapEnhancement(): KotlinType = getEnhancement() ?: this
|
||||
|
||||
fun UnwrappedType.inheritEnhancement(origin: KotlinType, transform: (KotlinType) -> KotlinType): UnwrappedType =
|
||||
wrapEnhancement(origin.getEnhancement()?.let(transform))
|
||||
|
||||
fun UnwrappedType.inheritEnhancement(origin: KotlinType): UnwrappedType = wrapEnhancement(origin.getEnhancement())
|
||||
|
||||
fun UnwrappedType.wrapEnhancement(enhancement: KotlinType?): UnwrappedType {
|
||||
|
||||
@@ -68,7 +68,7 @@ abstract class KotlinTypePreparator : AbstractTypePreparator {
|
||||
unwrappedType
|
||||
}
|
||||
}
|
||||
}.inheritEnhancement(unwrappedType)
|
||||
}.inheritEnhancement(unwrappedType, ::prepareType)
|
||||
}
|
||||
|
||||
object Default : KotlinTypePreparator()
|
||||
|
||||
Reference in New Issue
Block a user