[FIR] Check for ConeErrorType in doUnify to prevent endless recursion

^KT-64625 Fixed
This commit is contained in:
Ivan Kochurkin
2024-01-05 14:17:50 +01:00
committed by Space Team
parent 567433cc12
commit 1f0fb5a1a8
7 changed files with 42 additions and 0 deletions
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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<FirTypeParameterSymbol, ConeTypeProjection>()
for (intersectedType in originalType.intersectedTypes) {
@@ -0,0 +1,8 @@
// FIR_IDENTICAL
// ISSUE: KT-64625
// !DIAGNOSTICS: -DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE
interface A<T1, T2>
interface B<X> : A<X, <!UNRESOLVED_REFERENCE!>T<!>?>
fun f(x: A<Int, <!UNRESOLVED_REFERENCE!>K<!>?>) = x as B
@@ -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