diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index ae6c188af14..3f825dae118 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -13031,6 +13031,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia public void testKt24158() throws Exception { runTest("compiler/testData/diagnostics/tests/exceptions/kt24158.kt"); } + + @Test + @TestMetadata("stackOverflowOnDoUnify.kt") + public void testStackOverflowOnDoUnify() throws Exception { + runTest("compiler/testData/diagnostics/tests/exceptions/stackOverflowOnDoUnify.kt"); + } } @Nested diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index 97d9688202a..39841f39348 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -13031,6 +13031,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated public void testKt24158() throws Exception { runTest("compiler/testData/diagnostics/tests/exceptions/kt24158.kt"); } + + @Test + @TestMetadata("stackOverflowOnDoUnify.kt") + public void testStackOverflowOnDoUnify() throws Exception { + runTest("compiler/testData/diagnostics/tests/exceptions/stackOverflowOnDoUnify.kt"); + } } @Nested diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index 84bf1261d06..028552243dd 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -13025,6 +13025,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir public void testKt24158() throws Exception { runTest("compiler/testData/diagnostics/tests/exceptions/kt24158.kt"); } + + @Test + @TestMetadata("stackOverflowOnDoUnify.kt") + public void testStackOverflowOnDoUnify() throws Exception { + runTest("compiler/testData/diagnostics/tests/exceptions/stackOverflowOnDoUnify.kt"); + } } @Nested diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index b63aafd727d..be00615db5a 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -13031,6 +13031,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia public void testKt24158() throws Exception { runTest("compiler/testData/diagnostics/tests/exceptions/kt24158.kt"); } + + @Test + @TestMetadata("stackOverflowOnDoUnify.kt") + public void testStackOverflowOnDoUnify() throws Exception { + runTest("compiler/testData/diagnostics/tests/exceptions/stackOverflowOnDoUnify.kt"); + } } @Nested diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUnification.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUnification.kt index 8b78e813465..079443222bf 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUnification.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUnification.kt @@ -26,6 +26,10 @@ fun FirSession.doUnify( val originalType = originalTypeProjection.type?.lowerBoundIfFlexible()?.fullyExpandedType(this) val typeWithParameters = typeWithParametersProjection.type?.lowerBoundIfFlexible()?.fullyExpandedType(this) + if (typeWithParameters is ConeErrorType) { + return true // Return true to avoid loosing `result` substitution + } + if (originalType is ConeIntersectionType) { val intersectionResult = mutableMapOf() for (intersectedType in originalType.intersectedTypes) { diff --git a/compiler/testData/diagnostics/tests/exceptions/stackOverflowOnDoUnify.kt b/compiler/testData/diagnostics/tests/exceptions/stackOverflowOnDoUnify.kt new file mode 100644 index 00000000000..8b3b1b7aad8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/exceptions/stackOverflowOnDoUnify.kt @@ -0,0 +1,8 @@ +// FIR_IDENTICAL +// ISSUE: KT-64625 +// !DIAGNOSTICS: -DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE + +interface A +interface B : AT?> + +fun f(x: AK?>) = x as B 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 87b1bf19489..223e46f5cae 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 @@ -13031,6 +13031,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { public void testKt24158() throws Exception { runTest("compiler/testData/diagnostics/tests/exceptions/kt24158.kt"); } + + @Test + @TestMetadata("stackOverflowOnDoUnify.kt") + public void testStackOverflowOnDoUnify() throws Exception { + runTest("compiler/testData/diagnostics/tests/exceptions/stackOverflowOnDoUnify.kt"); + } } @Nested