@@ -396,8 +396,6 @@ ActorIsolationRestriction ActorIsolationRestriction::forDeclaration(
396396 func->getName ());
397397 }
398398 } // TODO: need to handle protocol case here too?
399- return forDistributedActorSelf (isolation.getActor (),
400- /* isCrossActor*/ isAccessibleAcrossActors);
401399 }
402400 }
403401
@@ -1586,13 +1584,6 @@ namespace {
15861584 ValueDecl *decl = concDeclRef.getDecl ();
15871585 AsyncMarkingResult result = AsyncMarkingResult::NotFound;
15881586
1589- // if it is explicitly marked distributed actor independent,
1590- // it is synchronously accessible, no implicit async needed.
1591- if (decl->getAttrs ().hasAttribute <DistributedActorIndependentAttr>() ||
1592- decl->getAttrs ().hasAttribute <NonisolatedAttr>()) {
1593- return result;
1594- }
1595-
15961587 // is it an access to a property?
15971588 if (isPropOrSubscript (decl)) {
15981589 if (auto declRef = dyn_cast_or_null<DeclRefExpr>(context)) {
@@ -2247,9 +2238,7 @@ namespace {
22472238 !(isolatedActor.isActorSelf () &&
22482239 member->isInstanceMember () &&
22492240 isActorInitOrDeInitContext (getDeclContext ())
2250- ) &&
2251- !member->getAttrs ().hasAttribute <NonisolatedAttr>() &&
2252- !member->getAttrs ().hasAttribute <DistributedActorIndependentAttr>();
2241+ );
22532242
22542243 if (performDistributedChecks) {
22552244 if (auto func = dyn_cast<FuncDecl>(member)) {
@@ -2272,13 +2261,6 @@ namespace {
22722261 } // end FuncDecl
22732262
22742263 if (isPropOrSubscript (member)) {
2275- DeclAttributes &attrs = member->getAttrs ();
2276- if (attrs.hasAttribute <DistributedActorIndependentAttr>())
2277- return false ;
2278-
2279- if (attrs.hasAttribute <NonisolatedAttr>())
2280- return false ;
2281-
22822264 ctx.Diags .diagnose (
22832265 memberLoc, diag::distributed_actor_isolated_non_self_reference,
22842266 member->getDescriptiveKind (),
@@ -2329,12 +2311,7 @@ namespace {
23292311 } else {
23302312 // it is some other member and since we only allow distributed
23312313 // funcs this definitely is distributed-actor-isolated
2332- auto distributedAccessAllowed =
2333- func->isDistributed () ||
2334- member->getAttrs ()
2335- .hasAttribute <DistributedActorIndependentAttr>() ||
2336- member->getAttrs ().hasAttribute <NonisolatedAttr>();
2337- if (!distributedAccessAllowed) {
2314+ if (!func->isDistributed ()) {
23382315 ctx.Diags .diagnose (
23392316 memberLoc,
23402317 diag::distributed_actor_isolated_non_self_reference,
@@ -2596,17 +2573,23 @@ static Optional<ActorIsolation> getIsolationFromAttributes(
25962573 // If any of them are present, use that attribute.
25972574 auto nonisolatedAttr = decl->getAttrs ().getAttribute <NonisolatedAttr>();
25982575 auto globalActorAttr = decl->getGlobalActorAttr ();
2576+ auto distributedActorIndependentAttr =
2577+ decl->getAttrs ().getAttribute <DistributedActorIndependentAttr>();
25992578
26002579 // Remove implicit attributes if we only care about explicit ones.
26012580 if (onlyExplicit) {
26022581 if (nonisolatedAttr && nonisolatedAttr->isImplicit ())
26032582 nonisolatedAttr = nullptr ;
26042583 if (globalActorAttr && globalActorAttr->first ->isImplicit ())
26052584 globalActorAttr = None;
2585+ if (distributedActorIndependentAttr &&
2586+ distributedActorIndependentAttr->isImplicit ())
2587+ distributedActorIndependentAttr = nullptr ;
26062588 }
26072589
26082590 unsigned numIsolationAttrs =
2609- (nonisolatedAttr ? 1 : 0 ) + (globalActorAttr ? 1 : 0 );
2591+ (nonisolatedAttr ? 1 : 0 ) + (globalActorAttr ? 1 : 0 ) +
2592+ (distributedActorIndependentAttr ? 1 : 0 );
26102593 if (numIsolationAttrs == 0 )
26112594 return None;
26122595
@@ -2623,19 +2606,32 @@ static Optional<ActorIsolation> getIsolationFromAttributes(
26232606
26242607 if (globalActorAttr) {
26252608 if (shouldDiagnose) {
2626- decl->diagnose (
2627- diag::actor_isolation_multiple_attr, decl->getDescriptiveKind (),
2628- name, nonisolatedAttr->getAttrName (),
2629- globalActorAttr->second ->getName ().str ())
2630- .highlight (nonisolatedAttr->getRangeWithAt ())
2631- .highlight (globalActorAttr->first ->getRangeWithAt ());
2609+ if (globalActorAttr) {
2610+ const DeclAttribute *otherAttr =
2611+ nonisolatedAttr
2612+ ? static_cast <const DeclAttribute *>(nonisolatedAttr)
2613+ : distributedActorIndependentAttr;
2614+ decl->diagnose (
2615+ diag::actor_isolation_multiple_attr, decl->getDescriptiveKind (),
2616+ name, otherAttr->getAttrName (),
2617+ globalActorAttr->second ->getName ().str ())
2618+ .highlight (otherAttr->getRangeWithAt ())
2619+ .highlight (globalActorAttr->first ->getRangeWithAt ());
2620+ } else {
2621+ decl->diagnose (
2622+ diag::actor_isolation_multiple_attr, decl->getDescriptiveKind (),
2623+ name, nonisolatedAttr->getAttrName (),
2624+ distributedActorIndependentAttr->getAttrName ())
2625+ .highlight (nonisolatedAttr->getRangeWithAt ())
2626+ .highlight (distributedActorIndependentAttr->getRangeWithAt ());
2627+ }
26322628 }
26332629 }
26342630 }
26352631
2636- // If the declaration is explicitly marked 'nonisolated', report it as
2637- // independent.
2638- if (nonisolatedAttr) {
2632+ // If the declaration is explicitly marked 'nonisolated' or distributed
2633+ // actor- independent, report it as nonisolated .
2634+ if (nonisolatedAttr || distributedActorIndependentAttr ) {
26392635 return ActorIsolation::forIndependent ();
26402636 }
26412637
@@ -3089,17 +3085,7 @@ ActorIsolation ActorIsolationRequest::evaluate(
30893085 break ;
30903086 }
30913087
3092- case ActorIsolation::DistributedActorInstance: {
3093- // / 'distributed actor independent' implies 'nonisolated'
3094- if (value->isDistributedActorIndependent ()) {
3095- // TODO: rename 'distributed actor independent' to 'distributed(nonisolated)'
3096- value->getAttrs ().add (
3097- new (ctx) DistributedActorIndependentAttr (/* IsImplicit=*/ true ));
3098- value->getAttrs ().add (
3099- new (ctx) NonisolatedAttr (/* IsImplicit=*/ true ));
3100- }
3101- break ;
3102- }
3088+ case ActorIsolation::DistributedActorInstance:
31033089 case ActorIsolation::ActorInstance:
31043090 case ActorIsolation::Unspecified:
31053091 if (onlyGlobal)
0 commit comments