@@ -2605,11 +2605,8 @@ bool TypeCheckASTNodeAtLocRequest::evaluate(
26052605 if (auto *func = dyn_cast<FuncDecl>(DC)) {
26062606 if (Type builderType = getResultBuilderType (func)) {
26072607 if (func->getBody ()) {
2608- auto optBody = TypeChecker::applyResultBuilderBodyTransform (
2609- func, builderType,
2610- /* ClosuresInResultBuilderDontParticipateInInference=*/
2611- ctx.CompletionCallback == nullptr &&
2612- ctx.SolutionCallback == nullptr );
2608+ auto optBody =
2609+ TypeChecker::applyResultBuilderBodyTransform (func, builderType);
26132610 if ((ctx.CompletionCallback && ctx.CompletionCallback ->gotCallback ()) ||
26142611 (ctx.SolutionCallback && ctx.SolutionCallback ->gotCallback ())) {
26152612 // We already informed the completion callback of solutions found by
@@ -2632,31 +2629,14 @@ bool TypeCheckASTNodeAtLocRequest::evaluate(
26322629 }
26332630 }
26342631
2635- // The enclosing closure might be a single expression closure or a function
2636- // builder closure. In such cases, the body elements are type checked with
2637- // the closure itself. So we need to try type checking the enclosing closure
2638- // signature first unless it has already been type checked.
2632+ // If the context is a closure, type check the entire surrounding closure.
2633+ // Conjunction constraints ensure that statements unrelated to the one that
2634+ // contains the code completion token are not type checked.
26392635 if (auto CE = dyn_cast<ClosureExpr>(DC)) {
26402636 if (CE->getBodyState () == ClosureExpr::BodyState::Parsed) {
26412637 swift::typeCheckASTNodeAtLoc (
26422638 TypeCheckASTNodeAtLocContext::declContext (CE->getParent ()),
26432639 CE->getLoc ());
2644- // We need the actor isolation of the closure to be set so that we can
2645- // annotate results that are on the same global actor.
2646- // Since we are evaluating TypeCheckASTNodeAtLocRequest for every closure
2647- // from outermost to innermost, we don't want to call checkActorIsolation,
2648- // because that would cause actor isolation to be checked multiple times
2649- // for nested closures. Instead, call determineClosureActorIsolation
2650- // directly and set the closure's actor isolation manually. We can
2651- // guarantee of that the actor isolation of enclosing closures have their
2652- // isolation checked before nested ones are being checked by the way
2653- // TypeCheckASTNodeAtLocRequest is called multiple times, as described
2654- // above.
2655- auto ActorIsolation = determineClosureActorIsolation (
2656- CE, __Expr_getType, __AbstractClosureExpr_getActorIsolation);
2657- CE->setActorIsolation (ActorIsolation);
2658- // Type checking the parent closure also type checked this node.
2659- // Nothing to do anymore.
26602640 return false ;
26612641 }
26622642 }
0 commit comments