diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 41c30f7165d..382de5ba9f8 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -14795,12 +14795,6 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt49101.kt"); } - @Test - @TestMetadata("kt52782.kt") - public void testKt52782() throws Exception { - runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt52782.kt"); - } - @Test @TestMetadata("memberScopeOfCaptured.kt") public void testMemberScopeOfCaptured() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index dad2fe7c327..14e2e62bf58 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -14795,12 +14795,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt49101.kt"); } - @Test - @TestMetadata("kt52782.kt") - public void testKt52782() throws Exception { - runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt52782.kt"); - } - @Test @TestMetadata("memberScopeOfCaptured.kt") public void testMemberScopeOfCaptured() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index 2e41a1ac567..018c36367bb 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -14795,12 +14795,6 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt49101.kt"); } - @Test - @TestMetadata("kt52782.kt") - public void testKt52782() throws Exception { - runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt52782.kt"); - } - @Test @TestMetadata("memberScopeOfCaptured.kt") public void testMemberScopeOfCaptured() throws Exception { diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/NewTypeSubstitutor.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/NewTypeSubstitutor.kt index 6f5759dc0aa..6f1b4f79e37 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/NewTypeSubstitutor.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/NewTypeSubstitutor.kt @@ -106,8 +106,8 @@ interface NewTypeSubstitutor : TypeSubstitutorMarker { val innerType = capturedType.lowerType ?: capturedType.constructor.projection.type.unwrap() val substitutedInnerType = substitute(innerType, keepAnnotation, runCapturedChecks = false) - val (projectionSupertype, boundSupertypes) = - capturedType.constructor.transformSupertypes { substitute(it, keepAnnotation, runCapturedChecks = false) ?: it } + val substitutedSuperTypes = + capturedType.constructor.supertypes.map { substitute(it, keepAnnotation, runCapturedChecks = false) ?: it } if (substitutedInnerType != null) { return if (substitutedInnerType.isCaptured()) substitutedInnerType else { @@ -116,7 +116,7 @@ interface NewTypeSubstitutor : TypeSubstitutorMarker { NewCapturedTypeConstructor( TypeProjectionImpl(typeConstructor.projection.projectionKind, substitutedInnerType), typeParameter = typeConstructor.typeParameter - ).also { it.initializeSupertypes(projectionSupertype, boundSupertypes) }, + ).also { it.initializeSupertypes(substitutedSuperTypes) }, lowerType = if (capturedType.lowerType != null) substitutedInnerType else null ) } diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/kt52782.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/kt52782.kt deleted file mode 100644 index 1b8cb3ea392..00000000000 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/kt52782.kt +++ /dev/null @@ -1,13 +0,0 @@ -// FIR_IDENTICAL -// FILE: Foo.java -public abstract class Foo>> { - abstract String getTest(); -} - -// FILE: Bar.java -public abstract class Bar>> {} - -// FILE: main.kt -fun box(foo: Foo<*>) { - foo.test // unresolved in 1.7.0, OK before -} diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/kt52782.txt b/compiler/testData/diagnostics/tests/inference/capturedTypes/kt52782.txt deleted file mode 100644 index b1d922751e5..00000000000 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/kt52782.txt +++ /dev/null @@ -1,18 +0,0 @@ -package - -public fun box(/*0*/ foo: Foo<*>): kotlin.Unit - -public abstract class Bar!>!> { - public constructor Bar!>!>() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public abstract class Foo!>!> { - public constructor Foo!>!>() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public/*package*/ abstract fun getTest(): kotlin.String! - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/testData/diagnostics/tests/inference/kt47316.kt b/compiler/testData/diagnostics/tests/inference/kt47316.kt index b36c5dcf9df..f881ef0e15d 100644 --- a/compiler/testData/diagnostics/tests/inference/kt47316.kt +++ b/compiler/testData/diagnostics/tests/inference/kt47316.kt @@ -30,7 +30,7 @@ fun String.asFsdAddress(): String { fun box(): String { val state = Test().state if (state is GoBuildingRunningState<*>) { - state.buildingWorkingDirectory.asFsdAddress() + state.buildingWorkingDirectory.asFsdAddress() } return "OK" } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 1386543b287..80c6d6e7151 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -14801,12 +14801,6 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt49101.kt"); } - @Test - @TestMetadata("kt52782.kt") - public void testKt52782() throws Exception { - runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt52782.kt"); - } - @Test @TestMetadata("memberScopeOfCaptured.kt") public void testMemberScopeOfCaptured() throws Exception { diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/checker/NewCapturedType.kt b/core/descriptors/src/org/jetbrains/kotlin/types/checker/NewCapturedType.kt index 44093c37c4d..55eb1b8207a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/checker/NewCapturedType.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/checker/NewCapturedType.kt @@ -173,16 +173,16 @@ private fun captureArguments(type: UnwrappedType, status: CaptureStatus): List) { + fun initializeSupertypes(supertypes: List) { assert(this.supertypesComputation == null) { - "Already initialized! oldValue = ${this.supertypesComputation}, newValue = $boundSupertypes" + "Already initialized! oldValue = ${this.supertypesComputation}, newValue = $supertypes" } - this.projectionSupertype = projectionSupertype - this.supertypesComputation = { boundSupertypes } - } - - override fun getSupertypes(): List = buildList { - projectionSupertype?.let { add(it) } - boundSupertypes?.let { addAll(it) } - } - - fun transformSupertypes(transformation: (UnwrappedType) -> UnwrappedType): Pair> { - val projectionSupertypeTransformed = projectionSupertype?.let(transformation) - val boundSupertypesTransformed = boundSupertypes?.map(transformation) ?: emptyList() - return projectionSupertypeTransformed to boundSupertypesTransformed + this.supertypesComputation = { supertypes } } + override fun getSupertypes() = _supertypes ?: emptyList() override fun getParameters(): List = emptyList() override fun isFinal() = false