@@ -1468,10 +1468,10 @@ namespace {
1468
1468
}
1469
1469
}
1470
1470
1471
- // "Defer" blocks are treated as if they are in their enclosing context.
1472
- if ( auto func = dyn_cast<FuncDecl>(dc)) {
1473
- if (func->isDeferBody ())
1474
- continue ;
1471
+ if ( auto func = dyn_cast<AbstractFunctionDecl>(dc)) {
1472
+ // @Sendable functions are nonisolated.
1473
+ if (func->isSendable ())
1474
+ return ReferencedActor (var, ReferencedActor::SendableFunction) ;
1475
1475
}
1476
1476
1477
1477
// Check isolation of the context itself. We do this separately
@@ -1480,9 +1480,14 @@ namespace {
1480
1480
switch (auto isolation = getActorIsolationOfContext (dc)) {
1481
1481
case ActorIsolation::Independent:
1482
1482
case ActorIsolation::Unspecified:
1483
- if (auto func = dyn_cast<AbstractFunctionDecl>(dc)) {
1484
- if (func->isSendable ())
1485
- return ReferencedActor (var, ReferencedActor::SendableFunction);
1483
+ // Local functions can capture an isolated parameter.
1484
+ // FIXME: This really should be modeled by getActorIsolationOfContext.
1485
+ if (isa<FuncDecl>(dc) && cast<FuncDecl>(dc)->isLocalCapture ()) {
1486
+ // FIXME: Local functions could presumably capture an isolated
1487
+ // parameter that isn't 'self'.
1488
+ if (isPotentiallyIsolated &&
1489
+ (var->isSelfParameter () || var->isSelfParamCapture ()))
1490
+ continue ;
1486
1491
}
1487
1492
1488
1493
return ReferencedActor (var, ReferencedActor::NonIsolatedContext);
@@ -1493,12 +1498,6 @@ namespace {
1493
1498
var, isolation.getGlobalActor ());
1494
1499
1495
1500
case ActorIsolation::ActorInstance:
1496
- // FIXME: Local functions could presumably capture an isolated
1497
- // parameter that isn't'self'.
1498
- if (isPotentiallyIsolated &&
1499
- (var->isSelfParameter () || var->isSelfParamCapture ()))
1500
- return ReferencedActor (var, ReferencedActor::Isolated);
1501
-
1502
1501
break ;
1503
1502
}
1504
1503
}
0 commit comments