[FIR] Add proper constraint if Unit upper bound leads to Unit lambda return type

#KT-63524 Fixed
This commit is contained in:
Kirill Rakhman
2023-12-11 10:13:39 +01:00
committed by Space Team
parent ce4eecebf4
commit 8a863e00ba
9 changed files with 46 additions and 6 deletions
@@ -17052,6 +17052,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/inference/underscoredTypeInForbiddenPositions.kt");
}
@Test
@TestMetadata("UnitUpperboundLambdaReturnType.kt")
public void testUnitUpperboundLambdaReturnType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/UnitUpperboundLambdaReturnType.kt");
}
@Test
@TestMetadata("unsoundness1.kt")
public void testUnsoundness1() throws Exception {
@@ -17058,6 +17058,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/inference/underscoredTypeInForbiddenPositions.kt");
}
@Test
@TestMetadata("UnitUpperboundLambdaReturnType.kt")
public void testUnitUpperboundLambdaReturnType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/UnitUpperboundLambdaReturnType.kt");
}
@Test
@TestMetadata("unsoundness1.kt")
public void testUnsoundness1() throws Exception {
@@ -201,10 +201,10 @@ class PostponedArgumentsAnalyzer(
}
}
if (!hasExpressionInReturnArguments && !lambdaExpectedTypeIsUnit) {
if (!hasExpressionInReturnArguments) {
builder.addSubtypeConstraint(
components.session.builtinTypes.unitType.type,
returnTypeRef.type,
substitute(lambda.returnType),
ConeLambdaArgumentConstraintPosition(lambda.atom)
)
}