[FIR] Add proper constraint if Unit upper bound leads to Unit lambda return type
#KT-63524 Fixed
This commit is contained in:
committed by
Space Team
parent
ce4eecebf4
commit
8a863e00ba
+6
@@ -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 {
|
||||
|
||||
+6
@@ -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 {
|
||||
|
||||
+2
-2
@@ -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)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user