File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -5287,6 +5287,10 @@ class ConstraintSystem {
52875287 // / part of the constraint system.
52885288 void forEachExpr (Expr *expr, llvm::function_ref<Expr *(Expr *)> callback);
52895289
5290+ // / Determine whether one of the parent closures the given one is nested
5291+ // / in (if any) has a result builder applied to its body.
5292+ bool isInResultBuilderContext (ClosureExpr *closure) const ;
5293+
52905294 SWIFT_DEBUG_DUMP;
52915295 SWIFT_DEBUG_DUMPER (dump(Expr *));
52925296
Original file line number Diff line number Diff line change @@ -919,6 +919,19 @@ bool ConstraintSystem::generateConstraints(ClosureExpr *closure) {
919919 return false ;
920920}
921921
922+ bool ConstraintSystem::isInResultBuilderContext (ClosureExpr *closure) const {
923+ if (!closure->hasSingleExpressionBody ()) {
924+ auto *DC = closure->getParent ();
925+ do {
926+ if (auto *parentClosure = dyn_cast<ClosureExpr>(DC)) {
927+ if (resultBuilderTransformed.count (parentClosure))
928+ return true ;
929+ }
930+ } while ((DC = DC->getParent ()));
931+ }
932+ return false ;
933+ }
934+
922935bool isConditionOfStmt (ConstraintLocatorBuilder locator) {
923936 auto last = locator.last ();
924937 if (!(last && last->is <LocatorPathElt::Condition>()))
You can’t perform that action at this time.
0 commit comments