@@ -8995,14 +8995,31 @@ ExprWalker::rewriteTarget(SolutionApplicationTarget target) {
8995
8995
if (cs.isDebugMode ()) {
8996
8996
// If target is a multi-statement closure or
8997
8997
// a tap expression, expression will not be fully
8998
- // type checked until these types are visited in
8998
+ // type checked until these expressions are visited in
8999
8999
// processDelayed().
9000
+ bool isPartial = false ;
9001
+ resultExpr->forEachChildExpr ([&](Expr *child) -> Expr * {
9002
+ if (auto *closure = dyn_cast<ClosureExpr>(child)) {
9003
+ if (!closure->hasSingleExpressionBody ()) {
9004
+ isPartial = true ;
9005
+ return nullptr ;
9006
+ }
9007
+ }
9008
+ if (isa<TapExpr>(child)) {
9009
+ isPartial = true ;
9010
+ return nullptr ;
9011
+ }
9012
+ return child;
9013
+ });
9014
+
9000
9015
auto &log = llvm::errs ();
9001
- if (!ClosuresToTypeCheck. empty () || !TapsToTypeCheck. empty () ) {
9016
+ if (isPartial ) {
9002
9017
log << " ---Partially type-checked expression---\n " ;
9003
- resultExpr-> dump (log);
9004
- log << " \n " ;
9018
+ } else {
9019
+ log << " ---Type-checked expression--- \n " ;
9005
9020
}
9021
+ resultExpr->dump (log);
9022
+ log << " \n " ;
9006
9023
}
9007
9024
}
9008
9025
@@ -9052,7 +9069,7 @@ Optional<SolutionApplicationTarget> ConstraintSystem::applySolution(
9052
9069
auto resultTarget = walker.rewriteTarget (target);
9053
9070
if (!resultTarget)
9054
9071
return None;
9055
-
9072
+
9056
9073
// Visit closures that have non-single expression bodies, tap expressions,
9057
9074
// and possibly other types of AST nodes which could only be processed
9058
9075
// after contextual expression.
@@ -9061,16 +9078,38 @@ Optional<SolutionApplicationTarget> ConstraintSystem::applySolution(
9061
9078
// If any of them failed to type check, bail.
9062
9079
if (hadError)
9063
9080
return None;
9064
-
9065
- rewriter.finalize ();
9066
9081
9067
- if (isDebugMode ()) {
9082
+ bool isPartial = false ;
9083
+ resultTarget->getAsExpr ()->forEachChildExpr ([&](Expr *child) -> Expr * {
9084
+ if (auto *closure = dyn_cast<ClosureExpr>(child)) {
9085
+ if (!closure->hasSingleExpressionBody ()) {
9086
+ isPartial = true ;
9087
+ return nullptr ;
9088
+ }
9089
+ }
9090
+ if (isa<TapExpr>(child)) {
9091
+ isPartial = true ;
9092
+ return nullptr ;
9093
+ }
9094
+ return child;
9095
+ });
9096
+
9097
+ if (isPartial) {
9068
9098
auto &log = llvm::errs ();
9069
9099
log << " ---Fully type-checked expression---\n " ;
9070
9100
resultTarget->getAsExpr ()->dump (log);
9071
9101
log << " \n " ;
9072
9102
}
9073
9103
9104
+ rewriter.finalize ();
9105
+
9106
+ // if (isDebugMode()) {
9107
+ // auto &log = llvm::errs();
9108
+ // log << "---Fully type-checked expression---\n";
9109
+ // resultTarget->getAsExpr()->dump(log);
9110
+ // log << "\n";
9111
+ // }
9112
+
9074
9113
return resultTarget;
9075
9114
}
9076
9115
0 commit comments