@@ -5709,16 +5709,18 @@ static bool hasCurriedSelf(ConstraintSystem &cs, ConcreteDeclRef callee,
57095709}
57105710
57115711// / Apply the contextually Sendable flag to the given expression,
5712- static void applyUnsafeConcurrent (
5713- Expr *expr, bool sendable, bool forMainActor) {
5712+ static void applyContextualClosureFlags (
5713+ Expr *expr, bool sendable, bool forMainActor, bool implicitSelfCapture ) {
57145714 if (auto closure = dyn_cast<ClosureExpr>(expr)) {
57155715 closure->setUnsafeConcurrent (sendable, forMainActor);
5716+ closure->setAllowsImplicitSelfCapture (implicitSelfCapture);
57165717 return ;
57175718 }
57185719
57195720 if (auto captureList = dyn_cast<CaptureListExpr>(expr)) {
5720- applyUnsafeConcurrent (
5721- captureList->getClosureBody (), sendable, forMainActor);
5721+ applyContextualClosureFlags (
5722+ captureList->getClosureBody (), sendable, forMainActor,
5723+ implicitSelfCapture);
57225724 }
57235725}
57245726
@@ -5803,7 +5805,8 @@ Expr *ExprRewriter::coerceCallArguments(
58035805
58045806 // Quickly test if any further fix-ups for the argument types are necessary.
58055807 if (AnyFunctionType::equalParams (args, params) &&
5806- !shouldInjectWrappedValuePlaceholder)
5808+ !shouldInjectWrappedValuePlaceholder &&
5809+ !paramInfo.anyContextualInfo ())
58075810 return arg;
58085811
58095812 // Apply labels to arguments.
@@ -5954,9 +5957,10 @@ Expr *ExprRewriter::coerceCallArguments(
59545957 bool isUnsafeSendable = paramInfo.isUnsafeSendable (paramIdx);
59555958 bool isMainActor = paramInfo.isUnsafeMainActor (paramIdx) ||
59565959 (isUnsafeSendable && apply && isMainDispatchQueue (apply->getFn ()));
5957- applyUnsafeConcurrent (
5960+ bool isImplicitSelfCapture = paramInfo.isImplicitSelfCapture (paramIdx);
5961+ applyContextualClosureFlags (
59585962 arg, isUnsafeSendable && contextUsesConcurrencyFeatures (dc),
5959- isMainActor);
5963+ isMainActor, isImplicitSelfCapture );
59605964
59615965 // If the types exactly match, this is easy.
59625966 auto paramType = param.getOldType ();
0 commit comments