@@ -2543,7 +2543,8 @@ namespace {
2543
2543
// / Determine whether code in the given use context might execute
2544
2544
// / concurrently with code in the definition context.
2545
2545
bool mayExecuteConcurrentlyWith (
2546
- const DeclContext *useContext, const DeclContext *defContext);
2546
+ const DeclContext *useContext, const DeclContext *defContext,
2547
+ bool includeSending = false );
2547
2548
2548
2549
// / If the subexpression is a reference to a mutable local variable from a
2549
2550
// / different context, record its parent. We'll query this as part of
@@ -3055,8 +3056,8 @@ namespace {
3055
3056
// by region isolation? Or should it always be handled by region
3056
3057
// isolation?
3057
3058
if (mayExecuteConcurrentlyWith (
3058
- localFunc.getAsDeclContext (), getDeclContext ()) ||
3059
- (explicitClosure && explicitClosure-> isPassedToSendingParameter () )) {
3059
+ localFunc.getAsDeclContext (), getDeclContext (),
3060
+ /* includeSending */ true )) {
3060
3061
auto innermostGenericDC = localFunc.getAsDeclContext ();
3061
3062
while (innermostGenericDC && !innermostGenericDC->isGenericContext ())
3062
3063
innermostGenericDC = innermostGenericDC->getParent ();
@@ -4816,7 +4817,8 @@ ActorIsolation ActorIsolationChecker::determineClosureIsolation(
4816
4817
}
4817
4818
4818
4819
bool ActorIsolationChecker::mayExecuteConcurrentlyWith (
4819
- const DeclContext *useContext, const DeclContext *defContext) {
4820
+ const DeclContext *useContext, const DeclContext *defContext,
4821
+ bool includeSending) {
4820
4822
// Fast path for when the use and definition contexts are the same.
4821
4823
if (useContext == defContext)
4822
4824
return false ;
@@ -4847,6 +4849,10 @@ bool ActorIsolationChecker::mayExecuteConcurrentlyWith(
4847
4849
if (closure->isSendable ())
4848
4850
return true ;
4849
4851
4852
+ if (auto *explicitClosure = dyn_cast<ClosureExpr>(closure)) {
4853
+ if (includeSending && explicitClosure->isPassedToSendingParameter ())
4854
+ return true ;
4855
+ }
4850
4856
}
4851
4857
4852
4858
if (auto func = dyn_cast<FuncDecl>(useContext)) {
0 commit comments