@@ -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
@@ -3051,12 +3052,9 @@ namespace {
3051
3052
}
3052
3053
}
3053
3054
3054
- // FIXME: When passing to a sending parameter, should this be handled
3055
- // by region isolation? Or should it always be handled by region
3056
- // isolation?
3057
3055
if (mayExecuteConcurrentlyWith (
3058
- localFunc.getAsDeclContext (), getDeclContext ()) ||
3059
- (explicitClosure && explicitClosure-> isPassedToSendingParameter () )) {
3056
+ localFunc.getAsDeclContext (), getDeclContext (),
3057
+ /* includeSending */ true )) {
3060
3058
auto innermostGenericDC = localFunc.getAsDeclContext ();
3061
3059
while (innermostGenericDC && !innermostGenericDC->isGenericContext ())
3062
3060
innermostGenericDC = innermostGenericDC->getParent ();
@@ -4816,7 +4814,8 @@ ActorIsolation ActorIsolationChecker::determineClosureIsolation(
4816
4814
}
4817
4815
4818
4816
bool ActorIsolationChecker::mayExecuteConcurrentlyWith (
4819
- const DeclContext *useContext, const DeclContext *defContext) {
4817
+ const DeclContext *useContext, const DeclContext *defContext,
4818
+ bool includeSending) {
4820
4819
// Fast path for when the use and definition contexts are the same.
4821
4820
if (useContext == defContext)
4822
4821
return false ;
@@ -4847,6 +4846,10 @@ bool ActorIsolationChecker::mayExecuteConcurrentlyWith(
4847
4846
if (closure->isSendable ())
4848
4847
return true ;
4849
4848
4849
+ if (auto *explicitClosure = dyn_cast<ClosureExpr>(closure)) {
4850
+ if (includeSending && explicitClosure->isPassedToSendingParameter ())
4851
+ return true ;
4852
+ }
4850
4853
}
4851
4854
4852
4855
if (auto func = dyn_cast<FuncDecl>(useContext)) {
0 commit comments