FIR: make deeper recursive type alias expansion check (see KT-37000)
This commit is contained in:
+6
@@ -452,6 +452,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/recursiveCallOnWhenWithSealedClass.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/recursiveCallOnWhenWithSealedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("recursiveTypeAlias.kt")
|
||||||
|
public void testRecursiveTypeAlias() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/recursiveTypeAlias.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("sealedClass.kt")
|
@TestMetadata("sealedClass.kt")
|
||||||
public void testSealedClass() throws Exception {
|
public void testSealedClass() throws Exception {
|
||||||
|
|||||||
+5
@@ -384,6 +384,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/recursiveCallOnWhenWithSealedClass.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/recursiveCallOnWhenWithSealedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("recursiveTypeAlias.kt")
|
||||||
|
public void testRecursiveTypeAlias() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/recursiveTypeAlias.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("sealedClass.kt")
|
@TestMetadata("sealedClass.kt")
|
||||||
public void testSealedClass() throws Exception {
|
public void testSealedClass() throws Exception {
|
||||||
runTest("compiler/fir/analysis-tests/testData/resolve/sealedClass.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/sealedClass.kt");
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
FILE: recursiveTypeAlias.kt
|
||||||
|
public abstract interface Something<D, T : R|() -> Something1<D>|> : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
public final typealias Something1<D> = <ERROR TYPE REF: Loop in supertype: /Something1 -> /Something>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
interface Something<D, T : () -> Something1<D>>
|
||||||
|
typealias Something1<D> = <!RECURSIVE_TYPEALIAS_EXPANSION!>Something<D, () -> Something1<D>><!>
|
||||||
+6
@@ -452,6 +452,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/recursiveCallOnWhenWithSealedClass.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/recursiveCallOnWhenWithSealedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("recursiveTypeAlias.kt")
|
||||||
|
public void testRecursiveTypeAlias() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/recursiveTypeAlias.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("sealedClass.kt")
|
@TestMetadata("sealedClass.kt")
|
||||||
public void testSealedClass() throws Exception {
|
public void testSealedClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -452,6 +452,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/recursiveCallOnWhenWithSealedClass.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/recursiveCallOnWhenWithSealedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("recursiveTypeAlias.kt")
|
||||||
|
public void testRecursiveTypeAlias() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/recursiveTypeAlias.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("sealedClass.kt")
|
@TestMetadata("sealedClass.kt")
|
||||||
public void testSealedClass() throws Exception {
|
public void testSealedClass() throws Exception {
|
||||||
|
|||||||
+10
-3
@@ -590,11 +590,18 @@ class SupertypeComputationSession {
|
|||||||
checkIsInLoop(supertypeFir)
|
checkIsInLoop(supertypeFir)
|
||||||
|
|
||||||
if (isTypeAlias) {
|
if (isTypeAlias) {
|
||||||
for (typeArgument in supertypeRef.type.typeArguments) {
|
fun checkTypeArgumentsRecursively(type: ConeKotlinType, visitedTypes: MutableSet<ConeKotlinType>) {
|
||||||
if (typeArgument is ConeClassLikeType) {
|
if (type in visitedTypes) return
|
||||||
checkIsInLoop(typeArgument.lookupTag.toSymbol(session)?.fir)
|
visitedTypes += type
|
||||||
|
for (typeArgument in type.typeArguments) {
|
||||||
|
if (typeArgument is ConeClassLikeType) {
|
||||||
|
checkIsInLoop(typeArgument.lookupTag.toSymbol(session)?.fir)
|
||||||
|
checkTypeArgumentsRecursively(typeArgument, visitedTypes)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkTypeArgumentsRecursively(supertypeRef.type, mutableSetOf())
|
||||||
}
|
}
|
||||||
|
|
||||||
resultSupertypeRefs.add(
|
resultSupertypeRefs.add(
|
||||||
|
|||||||
Reference in New Issue
Block a user