@@ -2881,18 +2881,12 @@ namespace {
2881
2881
struct CollectVarRefs : public ASTWalker {
2882
2882
ConstraintSystem &cs;
2883
2883
llvm::SmallPtrSet<TypeVariableType *, 4 > varRefs;
2884
- bool hasErrorExprs = false ;
2885
2884
2886
2885
CollectVarRefs (ConstraintSystem &cs) : cs(cs) { }
2887
2886
2888
2887
bool shouldWalkCaptureInitializerExpressions () override { return true ; }
2889
2888
2890
2889
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
-
2896
2890
// Retrieve type variables from references to var decls.
2897
2891
if (auto *declRef = dyn_cast<DeclRefExpr>(expr)) {
2898
2892
if (auto *varDecl = dyn_cast<VarDecl>(declRef->getDecl ())) {
@@ -2926,15 +2920,6 @@ namespace {
2926
2920
2927
2921
closure->walk (collectVarRefs);
2928
2922
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
-
2938
2923
auto inferredType = inferClosureType (closure);
2939
2924
if (!inferredType || inferredType->hasError ())
2940
2925
return Type ();
0 commit comments