@@ -1734,78 +1734,14 @@ AllowKeyPathWithoutComponents::create(ConstraintSystem &cs,
17341734}
17351735
17361736bool IgnoreInvalidResultBuilderBody::diagnose (const Solution &solution,
1737- bool asNote) const {
1738- switch (Phase) {
1739- // Handled below
1740- case ErrorInPhase::PreCheck:
1741- break ;
1742- case ErrorInPhase::ConstraintGeneration:
1743- return true ; // Already diagnosed by `matchResultBuilder`.
1744- }
1745-
1746- auto *S = castToExpr<ClosureExpr>(getAnchor ())->getBody ();
1747-
1748- class PreCheckWalker : public ASTWalker {
1749- DeclContext *DC;
1750- DiagnosticTransaction Transaction;
1751- // Check whether expression(s) in the body of the
1752- // result builder had any `ErrorExpr`s before pre-check.
1753- bool FoundErrorExpr = false ;
1754-
1755- public:
1756- PreCheckWalker (DeclContext *dc)
1757- : DC(dc), Transaction(dc->getASTContext ().Diags) {}
1758-
1759- std::pair<bool , Expr *> walkToExprPre (Expr *E) override {
1760- // This has to be checked before `preCheckExpression`
1761- // because pre-check would convert invalid references
1762- // into `ErrorExpr`s.
1763- E->forEachChildExpr ([&](Expr *expr) {
1764- FoundErrorExpr |= isa<ErrorExpr>(expr);
1765- return FoundErrorExpr ? nullptr : expr;
1766- });
1767-
1768- auto hasError = ConstraintSystem::preCheckExpression (
1769- E, DC, /* replaceInvalidRefsWithErrors=*/ true );
1770-
1771- return std::make_pair (false , hasError ? nullptr : E);
1772- }
1773-
1774- std::pair<bool , Stmt *> walkToStmtPre (Stmt *S) override {
1775- return std::make_pair (true , S);
1776- }
1777-
1778- // Ignore patterns because result builder pre-check does so as well.
1779- std::pair<bool , Pattern *> walkToPatternPre (Pattern *P) override {
1780- return std::make_pair (false , P);
1781- }
1782-
1783- bool diagnosed () const {
1784- // pre-check produced an error.
1785- if (Transaction.hasErrors ())
1786- return true ;
1787-
1788- // If there were `ErrorExpr`s before pre-check
1789- // they should have been diagnosed already by parser.
1790- if (FoundErrorExpr) {
1791- auto &DE = DC->getASTContext ().Diags ;
1792- return DE.hadAnyError ();
1793- }
1794-
1795- return false ;
1796- }
1797- };
1798-
1799- PreCheckWalker walker (solution.getDC());
1800- S->walk (walker);
1801-
1802- return walker.diagnosed();
1737+ bool asNote) const {
1738+ return true ; // Already diagnosed by `matchResultBuilder`.
18031739}
18041740
1805- IgnoreInvalidResultBuilderBody *IgnoreInvalidResultBuilderBody::create (
1806- ConstraintSystem &cs, ErrorInPhase phase, ConstraintLocator *locator) {
1807- return new (cs. getAllocator ())
1808- IgnoreInvalidResultBuilderBody (cs, phase , locator);
1741+ IgnoreInvalidResultBuilderBody *
1742+ IgnoreInvalidResultBuilderBody::create ( ConstraintSystem &cs,
1743+ ConstraintLocator *locator) {
1744+ return new (cs. getAllocator ()) IgnoreInvalidResultBuilderBody (cs, locator);
18091745}
18101746
18111747bool SpecifyContextualTypeForNil::diagnose (const Solution &solution,
0 commit comments