@@ -396,8 +396,6 @@ ActorIsolationRestriction ActorIsolationRestriction::forDeclaration(
396
396
func->getName ());
397
397
}
398
398
} // TODO: need to handle protocol case here too?
399
- return forDistributedActorSelf (isolation.getActor (),
400
- /* isCrossActor*/ isAccessibleAcrossActors);
401
399
}
402
400
}
403
401
@@ -1586,13 +1584,6 @@ namespace {
1586
1584
ValueDecl *decl = concDeclRef.getDecl ();
1587
1585
AsyncMarkingResult result = AsyncMarkingResult::NotFound;
1588
1586
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
-
1596
1587
// is it an access to a property?
1597
1588
if (isPropOrSubscript (decl)) {
1598
1589
if (auto declRef = dyn_cast_or_null<DeclRefExpr>(context)) {
@@ -2247,9 +2238,7 @@ namespace {
2247
2238
!(isolatedActor.isActorSelf () &&
2248
2239
member->isInstanceMember () &&
2249
2240
isActorInitOrDeInitContext (getDeclContext ())
2250
- ) &&
2251
- !member->getAttrs ().hasAttribute <NonisolatedAttr>() &&
2252
- !member->getAttrs ().hasAttribute <DistributedActorIndependentAttr>();
2241
+ );
2253
2242
2254
2243
if (performDistributedChecks) {
2255
2244
if (auto func = dyn_cast<FuncDecl>(member)) {
@@ -2272,13 +2261,6 @@ namespace {
2272
2261
} // end FuncDecl
2273
2262
2274
2263
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
-
2282
2264
ctx.Diags .diagnose (
2283
2265
memberLoc, diag::distributed_actor_isolated_non_self_reference,
2284
2266
member->getDescriptiveKind (),
@@ -2329,12 +2311,7 @@ namespace {
2329
2311
} else {
2330
2312
// it is some other member and since we only allow distributed
2331
2313
// 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 ()) {
2338
2315
ctx.Diags .diagnose (
2339
2316
memberLoc,
2340
2317
diag::distributed_actor_isolated_non_self_reference,
@@ -2596,17 +2573,23 @@ static Optional<ActorIsolation> getIsolationFromAttributes(
2596
2573
// If any of them are present, use that attribute.
2597
2574
auto nonisolatedAttr = decl->getAttrs ().getAttribute <NonisolatedAttr>();
2598
2575
auto globalActorAttr = decl->getGlobalActorAttr ();
2576
+ auto distributedActorIndependentAttr =
2577
+ decl->getAttrs ().getAttribute <DistributedActorIndependentAttr>();
2599
2578
2600
2579
// Remove implicit attributes if we only care about explicit ones.
2601
2580
if (onlyExplicit) {
2602
2581
if (nonisolatedAttr && nonisolatedAttr->isImplicit ())
2603
2582
nonisolatedAttr = nullptr ;
2604
2583
if (globalActorAttr && globalActorAttr->first ->isImplicit ())
2605
2584
globalActorAttr = None;
2585
+ if (distributedActorIndependentAttr &&
2586
+ distributedActorIndependentAttr->isImplicit ())
2587
+ distributedActorIndependentAttr = nullptr ;
2606
2588
}
2607
2589
2608
2590
unsigned numIsolationAttrs =
2609
- (nonisolatedAttr ? 1 : 0 ) + (globalActorAttr ? 1 : 0 );
2591
+ (nonisolatedAttr ? 1 : 0 ) + (globalActorAttr ? 1 : 0 ) +
2592
+ (distributedActorIndependentAttr ? 1 : 0 );
2610
2593
if (numIsolationAttrs == 0 )
2611
2594
return None;
2612
2595
@@ -2623,19 +2606,32 @@ static Optional<ActorIsolation> getIsolationFromAttributes(
2623
2606
2624
2607
if (globalActorAttr) {
2625
2608
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
+ }
2632
2628
}
2633
2629
}
2634
2630
}
2635
2631
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 ) {
2639
2635
return ActorIsolation::forIndependent ();
2640
2636
}
2641
2637
@@ -3089,17 +3085,7 @@ ActorIsolation ActorIsolationRequest::evaluate(
3089
3085
break ;
3090
3086
}
3091
3087
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:
3103
3089
case ActorIsolation::ActorInstance:
3104
3090
case ActorIsolation::Unspecified:
3105
3091
if (onlyGlobal)
0 commit comments