Do preparation of enhancement as well (for types with enhancement), during subtype checks

^KT-47899 Fixed
This commit is contained in:
Victor Petukhov
2021-07-29 11:23:13 +03:00
committed by teamcityserver
parent c5d783596d
commit 5684b6977a
6 changed files with 37 additions and 1 deletions
@@ -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<!>)
}
}
@@ -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 {
@@ -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 {
@@ -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()