Skip to content

Commit 5773099

Browse files
committed
[Sema] Don’t fail constraint generation if a closure contains an ErrorExpr
It appears like this was missed in swiftlang#60062.
1 parent 693f3e1 commit 5773099

File tree

1 file changed

+0
-15
lines changed

1 file changed

+0
-15
lines changed

lib/Sema/CSGen.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2881,18 +2881,12 @@ namespace {
28812881
struct CollectVarRefs : public ASTWalker {
28822882
ConstraintSystem &cs;
28832883
llvm::SmallPtrSet<TypeVariableType *, 4> varRefs;
2884-
bool hasErrorExprs = false;
28852884

28862885
CollectVarRefs(ConstraintSystem &cs) : cs(cs) { }
28872886

28882887
bool shouldWalkCaptureInitializerExpressions() override { return true; }
28892888

28902889
PreWalkResult<Expr *> walkToExprPre(Expr *expr) override {
2891-
// If there are any error expressions in this closure
2892-
// it wouldn't be possible to infer its type.
2893-
if (isa<ErrorExpr>(expr))
2894-
hasErrorExprs = true;
2895-
28962890
// Retrieve type variables from references to var decls.
28972891
if (auto *declRef = dyn_cast<DeclRefExpr>(expr)) {
28982892
if (auto *varDecl = dyn_cast<VarDecl>(declRef->getDecl())) {
@@ -2926,15 +2920,6 @@ namespace {
29262920

29272921
closure->walk(collectVarRefs);
29282922

2929-
// If walker discovered error expressions, let's fail constraint
2930-
// generation only if closure is going to participate
2931-
// in the type-check. This allows us to delay validation of
2932-
// multi-statement closures until body is opened.
2933-
if (CS.participatesInInference(closure) &&
2934-
collectVarRefs.hasErrorExprs) {
2935-
return Type();
2936-
}
2937-
29382923
auto inferredType = inferClosureType(closure);
29392924
if (!inferredType || inferredType->hasError())
29402925
return Type();

0 commit comments

Comments
 (0)