@@ -2559,7 +2559,8 @@ namespace {
2559
2559
// / Determine whether code in the given use context might execute
2560
2560
// / concurrently with code in the definition context.
2561
2561
bool mayExecuteConcurrentlyWith (
2562
- const DeclContext *useContext, const DeclContext *defContext);
2562
+ const DeclContext *useContext, const DeclContext *defContext,
2563
+ bool includeSending = false );
2563
2564
2564
2565
// / If the subexpression is a reference to a mutable local variable from a
2565
2566
// / different context, record its parent. We'll query this as part of
@@ -3067,12 +3068,9 @@ namespace {
3067
3068
}
3068
3069
}
3069
3070
3070
- // FIXME: When passing to a sending parameter, should this be handled
3071
- // by region isolation? Or should it always be handled by region
3072
- // isolation?
3073
3071
if (mayExecuteConcurrentlyWith (
3074
- localFunc.getAsDeclContext (), getDeclContext ()) ||
3075
- (explicitClosure && explicitClosure-> isPassedToSendingParameter () )) {
3072
+ localFunc.getAsDeclContext (), getDeclContext (),
3073
+ /* includeSending */ true )) {
3076
3074
auto innermostGenericDC = localFunc.getAsDeclContext ();
3077
3075
while (innermostGenericDC && !innermostGenericDC->isGenericContext ())
3078
3076
innermostGenericDC = innermostGenericDC->getParent ();
@@ -4834,7 +4832,8 @@ ActorIsolation ActorIsolationChecker::determineClosureIsolation(
4834
4832
}
4835
4833
4836
4834
bool ActorIsolationChecker::mayExecuteConcurrentlyWith (
4837
- const DeclContext *useContext, const DeclContext *defContext) {
4835
+ const DeclContext *useContext, const DeclContext *defContext,
4836
+ bool includeSending) {
4838
4837
// Fast path for when the use and definition contexts are the same.
4839
4838
if (useContext == defContext)
4840
4839
return false ;
@@ -4865,6 +4864,10 @@ bool ActorIsolationChecker::mayExecuteConcurrentlyWith(
4865
4864
if (closure->isSendable ())
4866
4865
return true ;
4867
4866
4867
+ if (auto *explicitClosure = dyn_cast<ClosureExpr>(closure)) {
4868
+ if (includeSending && explicitClosure->isPassedToSendingParameter ())
4869
+ return true ;
4870
+ }
4868
4871
}
4869
4872
4870
4873
if (auto func = dyn_cast<FuncDecl>(useContext)) {
0 commit comments