AA FE1.0: Fix StackOverflowError during resolution to a function w/ recursive type parameter

^KT-55825 Fixed
This commit is contained in:
Jinseong Jeon
2022-12-26 10:04:03 -08:00
committed by Yan Zhulanow
parent 0c516f8483
commit 2dca2b4827
7 changed files with 161 additions and 1 deletions
@@ -231,7 +231,12 @@ private fun KotlinType.hasReferenceOtherThan(allowedTypeParameterDescriptors: Se
declarationDescriptor !in allowedTypeParameterDescriptors ||
declarationDescriptor.upperBounds.any { it.hasReferenceOtherThan(allowedTypeParameterDescriptors) }
}
else -> arguments.any { it.type.hasReferenceOtherThan(allowedTypeParameterDescriptors) }
else -> arguments.any { typeProjection ->
// A star projection type (lazily) built by type parameter will be yet another type with a star projection,
// resulting in stack overflow if we keep checking allowed type parameter descriptors
!typeProjection.isStarProjection &&
typeProjection.type.hasReferenceOtherThan(allowedTypeParameterDescriptors)
}
}
}
@@ -700,6 +700,12 @@ public class Fe10IdeNormalAnalysisSourceModuleResolveCallTestGenerated extends A
runTest("analysis/analysis-api/testData/components/callResolver/resolveCall/qualifiedCalleeExpressionOfImplicitInvoke.kt");
}
@Test
@TestMetadata("recursiveTypeParameter.kt")
public void testRecursiveTypeParameter() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCall/recursiveTypeParameter.kt");
}
@Test
@TestMetadata("resolveCallInSuperConstructorParam.kt")
public void testResolveCallInSuperConstructorParam() throws Exception {