Skip to content

Commit da6bb36

Browse files
committed
[CSFix] Adjust IgnoreInvalidFunctionBuilderBody to return true only if errors are emitted
1 parent b2982fa commit da6bb36

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/Sema/CSFix.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,9 +1558,11 @@ bool IgnoreInvalidFunctionBuilderBody::diagnose(const Solution &solution,
15581558

15591559
class PreCheckWalker : public ASTWalker {
15601560
DeclContext *DC;
1561+
DiagnosticTransaction Transaction;
15611562

15621563
public:
1563-
PreCheckWalker(DeclContext *dc) : DC(dc) {}
1564+
PreCheckWalker(DeclContext *dc)
1565+
: DC(dc), Transaction(dc->getASTContext().Diags) {}
15641566

15651567
std::pair<bool, Expr *> walkToExprPre(Expr *E) override {
15661568
auto hasError = ConstraintSystem::preCheckExpression(
@@ -1576,12 +1578,16 @@ bool IgnoreInvalidFunctionBuilderBody::diagnose(const Solution &solution,
15761578
std::pair<bool, Pattern *> walkToPatternPre(Pattern *P) override {
15771579
return std::make_pair(false, P);
15781580
}
1581+
1582+
bool diagnosed() const {
1583+
return Transaction.hasDiagnostics();
1584+
}
15791585
};
15801586

15811587
PreCheckWalker walker(solution.getDC());
15821588
S->walk(walker);
15831589

1584-
return true;
1590+
return walker.diagnosed();
15851591
}
15861592

15871593
IgnoreInvalidFunctionBuilderBody *

0 commit comments

Comments
 (0)