Skip to content

Commit 5700516

Browse files
committed
[CSClosure] Make sure that body is always updated after solution application
It's possible that solution application either modifies or replaces the `BraceStmt` that represents closure body, so we need to make sure that body is always updated.
1 parent eda3824 commit 5700516

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/Sema/CSClosure.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,11 +1473,13 @@ bool ConstraintSystem::applySolutionToBody(Solution &solution,
14731473
auto closureType = cs.getType(closure)->castTo<FunctionType>();
14741474
ClosureConstraintApplication application(
14751475
solution, closure, closureType->getResult(), rewriteTarget);
1476-
application.visit(closure->getBody());
1476+
auto body = application.visit(closure->getBody());
14771477

1478-
if (application.hadError)
1478+
if (!body || application.hadError)
14791479
return true;
14801480

1481+
closure->setBody(cast<BraceStmt>(body.get<Stmt *>()),
1482+
closure->hasSingleExpressionBody());
14811483
closure->setBodyState(ClosureExpr::BodyState::TypeCheckedWithSignature);
14821484
return false;
14831485
}

0 commit comments

Comments
 (0)