Fix SOE when recursive type argument is used with star projection

#KT-41043 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2020-08-26 15:38:25 +03:00
parent 674e9e455f
commit 06a592c018
9 changed files with 53 additions and 1 deletions
@@ -12657,6 +12657,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/inference/plusAssignInsideLambda.kt");
}
@TestMetadata("recursiveConstraintInsideTypeArgumentWithStarProjection.kt")
public void testRecursiveConstraintInsideTypeArgumentWithStarProjection() throws Exception {
runTest("compiler/testData/codegen/box/inference/recursiveConstraintInsideTypeArgumentWithStarProjection.kt");
}
@TestMetadata("referenceToCatchParameterFromLambdaExpression.kt")
public void testReferenceToCatchParameterFromLambdaExpression() throws Exception {
runTest("compiler/testData/codegen/box/inference/referenceToCatchParameterFromLambdaExpression.kt");
@@ -403,7 +403,9 @@ class PostponedArgumentInputTypesResolver(
listOf(typeConstructor) + relatedVariables.filterIsInstance<TypeVariableTypeConstructor>()
}
type.arguments.isNotEmpty() -> {
type.arguments.flatMap { getAllDeeplyRelatedTypeVariables(it.type, variableDependencyProvider) }
type.arguments.flatMap {
if (it.isStarProjection) emptyList() else getAllDeeplyRelatedTypeVariables(it.type, variableDependencyProvider)
}
}
else -> emptyList()
}
@@ -0,0 +1,15 @@
class Foo<out T>(val key: T)
class Bar()
class KFlowable<T> {
fun <R> scan(initial: R, accumulator: (R, T) -> R) {}
}
fun test(k: KFlowable<Foo<Enum<*>>>) {
k.scan(Bar()) { s, t -> Bar() }
}
fun box(): String {
test(KFlowable())
return "OK"
}
@@ -13882,6 +13882,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/inference/plusAssignInsideLambda.kt");
}
@TestMetadata("recursiveConstraintInsideTypeArgumentWithStarProjection.kt")
public void testRecursiveConstraintInsideTypeArgumentWithStarProjection() throws Exception {
runTest("compiler/testData/codegen/box/inference/recursiveConstraintInsideTypeArgumentWithStarProjection.kt");
}
@TestMetadata("referenceToCatchParameterFromLambdaExpression.kt")
public void testReferenceToCatchParameterFromLambdaExpression() throws Exception {
runTest("compiler/testData/codegen/box/inference/referenceToCatchParameterFromLambdaExpression.kt");
@@ -13882,6 +13882,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/inference/plusAssignInsideLambda.kt");
}
@TestMetadata("recursiveConstraintInsideTypeArgumentWithStarProjection.kt")
public void testRecursiveConstraintInsideTypeArgumentWithStarProjection() throws Exception {
runTest("compiler/testData/codegen/box/inference/recursiveConstraintInsideTypeArgumentWithStarProjection.kt");
}
@TestMetadata("referenceToCatchParameterFromLambdaExpression.kt")
public void testReferenceToCatchParameterFromLambdaExpression() throws Exception {
runTest("compiler/testData/codegen/box/inference/referenceToCatchParameterFromLambdaExpression.kt");
@@ -12657,6 +12657,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/inference/plusAssignInsideLambda.kt");
}
@TestMetadata("recursiveConstraintInsideTypeArgumentWithStarProjection.kt")
public void testRecursiveConstraintInsideTypeArgumentWithStarProjection() throws Exception {
runTest("compiler/testData/codegen/box/inference/recursiveConstraintInsideTypeArgumentWithStarProjection.kt");
}
@TestMetadata("referenceToCatchParameterFromLambdaExpression.kt")
public void testReferenceToCatchParameterFromLambdaExpression() throws Exception {
runTest("compiler/testData/codegen/box/inference/referenceToCatchParameterFromLambdaExpression.kt");
@@ -10827,6 +10827,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/inference/plusAssignInsideLambda.kt");
}
@TestMetadata("recursiveConstraintInsideTypeArgumentWithStarProjection.kt")
public void testRecursiveConstraintInsideTypeArgumentWithStarProjection() throws Exception {
runTest("compiler/testData/codegen/box/inference/recursiveConstraintInsideTypeArgumentWithStarProjection.kt");
}
@TestMetadata("referenceToCatchParameterFromLambdaExpression.kt")
public void testReferenceToCatchParameterFromLambdaExpression() throws Exception {
runTest("compiler/testData/codegen/box/inference/referenceToCatchParameterFromLambdaExpression.kt");
@@ -10827,6 +10827,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/inference/plusAssignInsideLambda.kt");
}
@TestMetadata("recursiveConstraintInsideTypeArgumentWithStarProjection.kt")
public void testRecursiveConstraintInsideTypeArgumentWithStarProjection() throws Exception {
runTest("compiler/testData/codegen/box/inference/recursiveConstraintInsideTypeArgumentWithStarProjection.kt");
}
@TestMetadata("referenceToCatchParameterFromLambdaExpression.kt")
public void testReferenceToCatchParameterFromLambdaExpression() throws Exception {
runTest("compiler/testData/codegen/box/inference/referenceToCatchParameterFromLambdaExpression.kt");
@@ -10892,6 +10892,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/inference/plusAssignInsideLambda.kt");
}
@TestMetadata("recursiveConstraintInsideTypeArgumentWithStarProjection.kt")
public void testRecursiveConstraintInsideTypeArgumentWithStarProjection() throws Exception {
runTest("compiler/testData/codegen/box/inference/recursiveConstraintInsideTypeArgumentWithStarProjection.kt");
}
@TestMetadata("referenceToCatchParameterFromLambdaExpression.kt")
public void testReferenceToCatchParameterFromLambdaExpression() throws Exception {
runTest("compiler/testData/codegen/box/inference/referenceToCatchParameterFromLambdaExpression.kt");