diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Captured.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Captured.kt index f99226b806b..cc6a973addf 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Captured.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/strictMode/Captured.kt @@ -14,4 +14,4 @@ import org.jspecify.nullness.Nullable; public interface J2 extends J1 { } // FILE: kotlin.kt -private fun J2<*>.bar() = J1.foo(this) +private fun J2<*>.bar() = J1.foo(this) \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Captured.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Captured.kt index 535765d5a8d..aac2c7c41f7 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Captured.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Captured.kt @@ -1,4 +1,5 @@ // JSPECIFY_STATE: warn +// !LANGUAGE: +TypeEnhancementImprovementsInStrictMode // FILE: J1.java import org.jetbrains.annotations.Nullable; @@ -13,4 +14,4 @@ import org.jspecify.nullness.Nullable; public interface J2 extends J1 { } // FILE: kotlin.kt -private fun J2<*>.bar() = J1.foo(this) +private fun J2<*>.bar() = J1.foo(this) \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeWithEnhancement.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeWithEnhancement.kt index e05001bbfa1..776d77e01e2 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeWithEnhancement.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeWithEnhancement.kt @@ -33,7 +33,7 @@ class SimpleTypeWithEnhancement( ) : DelegatingSimpleType(), TypeWithEnhancement { - override val origin: UnwrappedType get() = delegate + override val origin get() = delegate override fun replaceAnnotations(newAnnotations: Annotations): SimpleType = origin.replaceAnnotations(newAnnotations).wrapEnhancement(enhancement) as SimpleType diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt b/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt index a4552542357..40e4b58177b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt @@ -142,7 +142,7 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy override fun SimpleTypeMarker.asCapturedType(): CapturedTypeMarker? { require(this is SimpleType, this::errorMessage) - return this as? NewCapturedType + return if (this is SimpleTypeWithEnhancement) origin.asCapturedType() else this as? NewCapturedType } override fun SimpleTypeMarker.asDefinitelyNotNullType(): DefinitelyNotNullTypeMarker? { @@ -326,9 +326,12 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy require(this is SimpleType, this::errorMessage) return !isError && constructor.declarationDescriptor !is TypeAliasDescriptor && - (constructor.declarationDescriptor != null || this is CapturedType || this is NewCapturedType || this is DefinitelyNotNullType || constructor is IntegerLiteralTypeConstructor) + (constructor.declarationDescriptor != null || this is CapturedType || this is NewCapturedType || this is DefinitelyNotNullType || constructor is IntegerLiteralTypeConstructor || isSingleClassifierTypeWithEnhancement()) } + private fun SimpleTypeMarker.isSingleClassifierTypeWithEnhancement() = + this is SimpleTypeWithEnhancement && origin.isSingleClassifierType() + override fun KotlinTypeMarker.contains(predicate: (KotlinTypeMarker) -> Boolean): Boolean { require(this is KotlinType, this::errorMessage) return containsInternal(this, predicate)