mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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.
This commit is contained in:
@@ -1473,11 +1473,13 @@ bool ConstraintSystem::applySolutionToBody(Solution &solution,
|
||||
auto closureType = cs.getType(closure)->castTo<FunctionType>();
|
||||
ClosureConstraintApplication application(
|
||||
solution, closure, closureType->getResult(), rewriteTarget);
|
||||
application.visit(closure->getBody());
|
||||
auto body = application.visit(closure->getBody());
|
||||
|
||||
if (application.hadError)
|
||||
if (!body || application.hadError)
|
||||
return true;
|
||||
|
||||
closure->setBody(cast<BraceStmt>(body.get<Stmt *>()),
|
||||
closure->hasSingleExpressionBody());
|
||||
closure->setBodyState(ClosureExpr::BodyState::TypeCheckedWithSignature);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user