@@ -5631,59 +5631,25 @@ static bool hasCurriedSelf(ConstraintSystem &cs, ConcreteDeclRef callee,
56315631
56325632// / Apply the contextually Sendable flag to the given expression,
56335633static void applyContextualClosureFlags (
5634- Expr *expr, bool sendable, bool forMainActor, bool implicitSelfCapture,
5635- bool inheritActorContext) {
5634+ Expr *expr, bool implicitSelfCapture, bool inheritActorContext) {
56365635 if (auto closure = dyn_cast<ClosureExpr>(expr)) {
5637- closure->setUnsafeConcurrent (sendable, forMainActor);
56385636 closure->setAllowsImplicitSelfCapture (implicitSelfCapture);
56395637 closure->setInheritsActorContext (inheritActorContext);
56405638 return ;
56415639 }
56425640
56435641 if (auto captureList = dyn_cast<CaptureListExpr>(expr)) {
56445642 applyContextualClosureFlags (
5645- captureList->getClosureBody (), sendable, forMainActor ,
5646- implicitSelfCapture, inheritActorContext);
5643+ captureList->getClosureBody (), implicitSelfCapture ,
5644+ inheritActorContext);
56475645 }
56485646
56495647 if (auto identity = dyn_cast<IdentityExpr>(expr)) {
56505648 applyContextualClosureFlags (
5651- identity->getSubExpr (), sendable, forMainActor,
5652- implicitSelfCapture, inheritActorContext);
5649+ identity->getSubExpr (), implicitSelfCapture, inheritActorContext);
56535650 }
56545651}
56555652
5656- // / Whether this is a reference to a method on the main dispatch queue.
5657- static bool isMainDispatchQueue (Expr *arg) {
5658- auto call = dyn_cast<DotSyntaxCallExpr>(arg);
5659- if (!call)
5660- return false ;
5661-
5662- auto memberRef = dyn_cast<MemberRefExpr>(
5663- call->getBase ()->getValueProvidingExpr ());
5664- if (!memberRef)
5665- return false ;
5666-
5667- auto member = memberRef->getMember ();
5668- if (member.getDecl ()->getName ().getBaseName ().userFacingName () != " main" )
5669- return false ;
5670-
5671- auto typeExpr = dyn_cast<TypeExpr>(
5672- memberRef->getBase ()->getValueProvidingExpr ());
5673- if (!typeExpr)
5674- return false ;
5675-
5676- Type baseType = typeExpr->getInstanceType ();
5677- if (!baseType)
5678- return false ;
5679-
5680- auto baseNominal = baseType->getAnyNominal ();
5681- if (!baseNominal)
5682- return false ;
5683-
5684- return baseNominal->getName ().str () == " DispatchQueue" ;
5685- }
5686-
56875653ArgumentList *ExprRewriter::coerceCallArguments (
56885654 ArgumentList *args, AnyFunctionType *funcType, ConcreteDeclRef callee,
56895655 ApplyExpr *apply, ConstraintLocatorBuilder locator,
@@ -5825,16 +5791,12 @@ ArgumentList *ExprRewriter::coerceCallArguments(
58255791 // for things like trailing closures and args to property wrapper params.
58265792 arg.setLabel (param.getLabel ());
58275793
5828- // Determine whether the parameter is unsafe Sendable or MainActor, and
5829- // record it as such.
5830- bool isUnsafeSendable = paramInfo.isUnsafeSendable (paramIdx);
5831- bool isMainActor = paramInfo.isUnsafeMainActor (paramIdx) ||
5832- (isUnsafeSendable && apply && isMainDispatchQueue (apply->getFn ()));
5794+ // Determine whether the closure argument should be treated as having
5795+ // implicit self capture or inheriting actor context.
58335796 bool isImplicitSelfCapture = paramInfo.isImplicitSelfCapture (paramIdx);
58345797 bool inheritsActorContext = paramInfo.inheritsActorContext (paramIdx);
58355798 applyContextualClosureFlags (
5836- argExpr, isUnsafeSendable && contextUsesConcurrencyFeatures (dc),
5837- isMainActor, isImplicitSelfCapture, inheritsActorContext);
5799+ argExpr, isImplicitSelfCapture, inheritsActorContext);
58385800
58395801 // If the types exactly match, this is easy.
58405802 auto paramType = param.getOldType ();
0 commit comments