@@ -1544,55 +1544,21 @@ namespace {
15441544 }
15451545
15461546 // / Get the actor isolation of the innermost relevant context.
1547- ActorIsolation getInnermostIsolatedContext (const DeclContext *constDC) {
1548- // Retrieve the actor isolation for a declaration somewhere in our
1549- // declaration context chain and map it into our own context so that
1550- // the types can be compared.
1551- auto getActorIsolation = [constDC](ValueDecl *value) {
1552- switch (auto isolation = swift::getActorIsolation (value)) {
1553- case ActorIsolation::ActorInstance:
1554- case ActorIsolation::Independent:
1555- case ActorIsolation::IndependentUnsafe:
1556- case ActorIsolation::Unspecified:
1557- return isolation;
1558-
1559- case ActorIsolation::GlobalActor:
1560- case ActorIsolation::GlobalActorUnsafe:
1561- return ActorIsolation::forGlobalActor (
1562- constDC->mapTypeIntoContext (isolation.getGlobalActor ()),
1563- isolation == ActorIsolation::GlobalActorUnsafe);
1564- }
1565- };
1566-
1567- auto dc = const_cast <DeclContext *>(constDC);
1568- while (!dc->isModuleScopeContext ()) {
1569- if (auto closure = dyn_cast<AbstractClosureExpr>(dc))
1570- return getActorIsolationOfContext (dc);
1571-
1572- // Functions have actor isolation defined on them.
1573- if (auto func = dyn_cast<AbstractFunctionDecl>(dc))
1574- return getActorIsolation (func);
1575-
1576- // Subscripts have actor isolation defined on them.
1577- if (auto subscript = dyn_cast<SubscriptDecl>(dc))
1578- return getActorIsolation (subscript);
1579-
1580- // Pattern binding declarations have actor isolation defined on their
1581- // properties, if any.
1582- if (auto init = dyn_cast<PatternBindingInitializer>(dc)) {
1583- auto var = init->getBinding ()->getAnchoringVarDecl (
1584- init->getBindingIndex ());
1585- if (var)
1586- return getActorIsolation (var);
1587-
1588- return ActorIsolation::forUnspecified ();
1589- }
1547+ ActorIsolation getInnermostIsolatedContext (DeclContext *dc) {
1548+ // Retrieve the actor isolation of the context.
1549+ switch (auto isolation = getActorIsolationOfContext (dc)) {
1550+ case ActorIsolation::ActorInstance:
1551+ case ActorIsolation::Independent:
1552+ case ActorIsolation::IndependentUnsafe:
1553+ case ActorIsolation::Unspecified:
1554+ return isolation;
15901555
1591- return ActorIsolation::forUnspecified ();
1556+ case ActorIsolation::GlobalActor:
1557+ case ActorIsolation::GlobalActorUnsafe:
1558+ return ActorIsolation::forGlobalActor (
1559+ dc->mapTypeIntoContext (isolation.getGlobalActor ()),
1560+ isolation == ActorIsolation::GlobalActorUnsafe);
15921561 }
1593-
1594- // At module scope, actor independence with safety is assumed.
1595- return ActorIsolation::forIndependent (ActorIndependentKind::Safe);
15961562 }
15971563
15981564 bool isInAsynchronousContext () const {
@@ -1704,7 +1670,7 @@ namespace {
17041670 bool isCrossActor,
17051671 Expr *context) {
17061672 ValueDecl *value = valueRef.getDecl ();
1707- auto declContext = getDeclContext ();
1673+ auto declContext = const_cast <DeclContext *>( getDeclContext () );
17081674
17091675 // Check whether we are within the same isolation context, in which
17101676 // case there is nothing further to check,
0 commit comments