@@ -1313,10 +1313,10 @@ namespace {
1313
1313
}
1314
1314
}
1315
1315
1316
- // "Defer" blocks are treated as if they are in their enclosing context.
1317
- if ( auto func = dyn_cast<FuncDecl>(dc)) {
1318
- if (func->isDeferBody ())
1319
- continue ;
1316
+ if ( auto func = dyn_cast<AbstractFunctionDecl>(dc)) {
1317
+ // @Sendable functions are nonisolated.
1318
+ if (func->isSendable ())
1319
+ return ReferencedActor (var, ReferencedActor::SendableFunction) ;
1320
1320
}
1321
1321
1322
1322
// Check isolation of the context itself. We do this separately
@@ -1325,9 +1325,14 @@ namespace {
1325
1325
switch (auto isolation = getActorIsolationOfContext (dc)) {
1326
1326
case ActorIsolation::Independent:
1327
1327
case ActorIsolation::Unspecified:
1328
- if (auto func = dyn_cast<AbstractFunctionDecl>(dc)) {
1329
- if (func->isSendable ())
1330
- return ReferencedActor (var, ReferencedActor::SendableFunction);
1328
+ // Local functions can capture an isolated parameter.
1329
+ // FIXME: This really should be modeled by getActorIsolationOfContext.
1330
+ if (isa<FuncDecl>(dc) && cast<FuncDecl>(dc)->isLocalCapture ()) {
1331
+ // FIXME: Local functions could presumably capture an isolated
1332
+ // parameter that isn't 'self'.
1333
+ if (isPotentiallyIsolated &&
1334
+ (var->isSelfParameter () || var->isSelfParamCapture ()))
1335
+ continue ;
1331
1336
}
1332
1337
1333
1338
return ReferencedActor (var, ReferencedActor::NonIsolatedContext);
@@ -1339,12 +1344,6 @@ namespace {
1339
1344
1340
1345
case ActorIsolation::ActorInstance:
1341
1346
case ActorIsolation::DistributedActorInstance:
1342
- // FIXME: Local functions could presumably capture an isolated
1343
- // parameter that isn't'self'.
1344
- if (isPotentiallyIsolated &&
1345
- (var->isSelfParameter () || var->isSelfParamCapture ()))
1346
- return ReferencedActor (var, ReferencedActor::Isolated);
1347
-
1348
1347
break ;
1349
1348
}
1350
1349
}
0 commit comments