@@ -6453,12 +6453,6 @@ static bool applyTypeToClosureExpr(ConstraintSystem &cs,
6453
6453
// If we found an explicit ClosureExpr, update its type.
6454
6454
if (auto CE = dyn_cast<ClosureExpr>(expr)) {
6455
6455
cs.setType (CE, toType);
6456
-
6457
- // If solution application for this closure is delayed, let's write the
6458
- // type into the ClosureExpr directly here, since the visitor won't.
6459
- if (!CE->hasSingleExpressionBody ())
6460
- CE->setType (toType);
6461
-
6462
6456
return true ;
6463
6457
}
6464
6458
@@ -8822,15 +8816,12 @@ namespace {
8822
8816
8823
8817
class ExprWalker : public ASTWalker , public SyntacticElementTargetRewriter {
8824
8818
ExprRewriter &Rewriter;
8825
- SmallVector<ClosureExpr *, 4 > ClosuresToTypeCheck;
8826
8819
SmallVector<Decl *, 4 > LocalDeclsToTypeCheck;
8827
8820
8828
8821
public:
8829
8822
ExprWalker (ExprRewriter &Rewriter) : Rewriter(Rewriter) { }
8830
8823
8831
8824
~ExprWalker () {
8832
- assert (ClosuresToTypeCheck.empty ());
8833
-
8834
8825
// Type-check any local decls encountered.
8835
8826
for (auto *D : LocalDeclsToTypeCheck)
8836
8827
TypeChecker::typeCheckDecl (D);
@@ -8849,37 +8840,6 @@ namespace {
8849
8840
return false ;
8850
8841
}
8851
8842
8852
- // / Check if there are any closures or tap expressions left to process separately.
8853
- bool hasDelayedTasks () { return !ClosuresToTypeCheck.empty (); }
8854
-
8855
- // / Process delayed closure bodies and `Tap` expressions.
8856
- // /
8857
- // / \returns true if any part of the processing fails.
8858
- bool processDelayed () {
8859
- bool hadError = false ;
8860
- auto &solution = Rewriter.solution ;
8861
- auto &cs = solution.getConstraintSystem ();
8862
-
8863
- while (!ClosuresToTypeCheck.empty ()) {
8864
- auto *closure = ClosuresToTypeCheck.pop_back_val ();
8865
- // If experimental multi-statement closure support
8866
- // is enabled, solution should have all of required
8867
- // information.
8868
- //
8869
- // Note that in this mode `ClosuresToTypeCheck` acts
8870
- // as a stack because multi-statement closures could
8871
- // have other multi-statement closures in the body.
8872
- hadError |= cs.applySolutionToBody (closure, *this );
8873
-
8874
- if (!hadError) {
8875
- TypeChecker::checkClosureAttributes (closure);
8876
- TypeChecker::checkParameterList (closure->getParameters (), closure);
8877
- }
8878
- }
8879
-
8880
- return hadError;
8881
- }
8882
-
8883
8843
MacroWalking getMacroWalkingBehavior () const override {
8884
8844
return MacroWalking::Arguments;
8885
8845
}
@@ -8959,12 +8919,6 @@ namespace {
8959
8919
8960
8920
case SolutionApplicationToFunctionResult::Failure:
8961
8921
return true ;
8962
-
8963
- case SolutionApplicationToFunctionResult::Delay: {
8964
- auto closure = cast<ClosureExpr>(fn.getAbstractClosureExpr ());
8965
- ClosuresToTypeCheck.push_back (closure);
8966
- return false ;
8967
- }
8968
8922
}
8969
8923
}
8970
8924
@@ -9817,31 +9771,8 @@ ExprWalker::rewriteTarget(SyntacticElementTarget target) {
9817
9771
result.setExpr (resultExpr);
9818
9772
9819
9773
if (cs.isDebugMode ()) {
9820
- // If target is a multi-statement closure or
9821
- // a tap expression, expression will not be fully
9822
- // type checked until these expressions are visited in
9823
- // processDelayed().
9824
- bool isPartial = false ;
9825
- resultExpr->forEachChildExpr ([&](Expr *child) -> Expr * {
9826
- if (auto *closure = dyn_cast<ClosureExpr>(child)) {
9827
- if (!closure->hasSingleExpressionBody ()) {
9828
- isPartial = true ;
9829
- return nullptr ;
9830
- }
9831
- }
9832
- if (isa<TapExpr>(child)) {
9833
- isPartial = true ;
9834
- return nullptr ;
9835
- }
9836
- return child;
9837
- });
9838
-
9839
9774
auto &log = llvm::errs ();
9840
- if (isPartial) {
9841
- log << " \n ---Partially type-checked expression---\n " ;
9842
- } else {
9843
- log << " \n ---Type-checked expression---\n " ;
9844
- }
9775
+ log << " \n ---Type-checked expression---\n " ;
9845
9776
resultExpr->dump (log);
9846
9777
log << " \n " ;
9847
9778
}
@@ -9902,29 +9833,6 @@ ConstraintSystem::applySolution(Solution &solution,
9902
9833
if (!resultTarget)
9903
9834
return std::nullopt;
9904
9835
9905
- auto needsPostProcessing = walker.hasDelayedTasks ();
9906
-
9907
- // Visit closures that have non-single expression bodies, tap expressions,
9908
- // and possibly other types of AST nodes which could only be processed
9909
- // after contextual expression.
9910
- bool hadError = walker.processDelayed ();
9911
-
9912
- // If any of them failed to type check, bail.
9913
- if (hadError)
9914
- return std::nullopt;
9915
-
9916
- if (isDebugMode ()) {
9917
- // If we had partially type-checked expressions, lets print
9918
- // fully type-checked target after processDelayed is done.
9919
- auto node = target.getAsASTNode ();
9920
- if (node && needsPostProcessing) {
9921
- auto &log = llvm::errs ();
9922
- log << " \n ---Fully type-checked target---\n " ;
9923
- node.dump (log);
9924
- log << " \n " ;
9925
- }
9926
- }
9927
-
9928
9836
rewriter.finalize ();
9929
9837
9930
9838
return resultTarget;
0 commit comments