Skip to content

Commit 62b2054

Browse files
committed
Remove @_distributedActorIndependent attribute entirely.
All its uses have been subsumed into `nonisolated`.
1 parent e0767e0 commit 62b2054

File tree

8 files changed

+14
-60
lines changed

8 files changed

+14
-60
lines changed

docs/ReferenceGuides/UnderscoredAttributes.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,6 @@ library), instead of at an arbitrary point in time.
113113
For more details, see the forum post on
114114
[dynamic method replacement](https://forums.swift.org/t/dynamic-method-replacement/16619).
115115

116-
## `@_distributedActorIndependent`
117-
118-
Marks a specific property of a distributed actor to be available even if the
119-
actor is remote.
120-
121-
This only applies to two distributed actor properties `address` and `transport`.
122-
It cannot be safely declared on any properties defined by ordinary Swift code.
123-
124116
## `@_effects(effectname)`
125117

126118
Tells the compiler that the implementation of the defined function is limited

include/swift/AST/Attr.def

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -658,12 +658,7 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(distributed, DistributedActor,
658658
APIBreakingToAdd | APIBreakingToRemove,
659659
118)
660660

661-
SIMPLE_DECL_ATTR(_distributedActorIndependent, DistributedActorIndependent,
662-
OnFunc | OnVar |
663-
DistributedOnly | UserInaccessible |
664-
ABIStableToAdd | ABIStableToRemove |
665-
APIBreakingToAdd | APIBreakingToRemove,
666-
119)
661+
// 110 is unused
667662

668663
SIMPLE_DECL_ATTR(_assemblyVision, EmitAssemblyVisionRemarks,
669664
OnFunc | UserInaccessible | NotSerialized | OnNominalType |

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4616,9 +4616,6 @@ ERROR(distributed_actor_user_defined_special_property,none,
46164616
"property %0 cannot be defined explicitly, as it conflicts with "
46174617
"distributed actor synthesized stored property",
46184618
(DeclName))
4619-
ERROR(distributed_actor_independent_property_must_be_let,none,
4620-
"_distributedActorIndependent can be applied to properties, however they must be 'let'",
4621-
())
46224619
NOTE(distributed_actor_isolated_property,none,
46234620
"distributed actor state is only available within the actor instance", // TODO: reword in terms of isolation
46244621
())

lib/Sema/DerivedConformanceDistributedActor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static ValueDecl *deriveDistributedActor_id(DerivedConformance &derived) {
105105
auto &C = derived.Context;
106106

107107
// ```
108-
// @_distributedActorIndependent
108+
// nonisolated
109109
// let id: AnyActorIdentity
110110
// ```
111111
auto propertyType = C.getAnyActorIdentityDecl()->getDeclaredInterfaceType();
@@ -133,7 +133,7 @@ static ValueDecl *deriveDistributedActor_actorTransport(
133133
auto &C = derived.Context;
134134

135135
// ```
136-
// @_distributedActorIndependent
136+
// nonisolated
137137
// let actorTransport: ActorTransport
138138
// ```
139139
// (no need for @actorIndependent because it is an immutable let)

lib/Sema/TypeCheckAttr.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
256256

257257
void visitActorAttr(ActorAttr *attr);
258258
void visitDistributedActorAttr(DistributedActorAttr *attr);
259-
void visitDistributedActorIndependentAttr(DistributedActorIndependentAttr *attr);
260259
void visitGlobalActorAttr(GlobalActorAttr *attr);
261260
void visitAsyncAttr(AsyncAttr *attr);
262261
void visitMarkerAttr(MarkerAttr *attr);
@@ -5510,16 +5509,6 @@ void AttributeChecker::visitNonisolatedAttr(NonisolatedAttr *attr) {
55105509
}
55115510
}
55125511

5513-
void AttributeChecker::visitDistributedActorIndependentAttr(DistributedActorIndependentAttr *attr) {
5514-
/// user-inaccessible _distributedActorIndependent can only be applied to let properties
5515-
if (auto var = dyn_cast<VarDecl>(D)) {
5516-
if (!var->isLet()) {
5517-
diagnoseAndRemoveAttr(attr, diag::distributed_actor_independent_property_must_be_let);
5518-
return;
5519-
}
5520-
}
5521-
}
5522-
55235512
void AttributeChecker::visitGlobalActorAttr(GlobalActorAttr *attr) {
55245513
auto nominal = dyn_cast<NominalTypeDecl>(D);
55255514
if (!nominal)

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2561,23 +2561,17 @@ static Optional<ActorIsolation> getIsolationFromAttributes(
25612561
// If any of them are present, use that attribute.
25622562
auto nonisolatedAttr = decl->getAttrs().getAttribute<NonisolatedAttr>();
25632563
auto globalActorAttr = decl->getGlobalActorAttr();
2564-
auto distributedActorIndependentAttr =
2565-
decl->getAttrs().getAttribute<DistributedActorIndependentAttr>();
25662564

25672565
// Remove implicit attributes if we only care about explicit ones.
25682566
if (onlyExplicit) {
25692567
if (nonisolatedAttr && nonisolatedAttr->isImplicit())
25702568
nonisolatedAttr = nullptr;
25712569
if (globalActorAttr && globalActorAttr->first->isImplicit())
25722570
globalActorAttr = None;
2573-
if (distributedActorIndependentAttr &&
2574-
distributedActorIndependentAttr->isImplicit())
2575-
distributedActorIndependentAttr = nullptr;
25762571
}
25772572

25782573
unsigned numIsolationAttrs =
2579-
(nonisolatedAttr ? 1 : 0) + (globalActorAttr ? 1 : 0) +
2580-
(distributedActorIndependentAttr ? 1 : 0);
2574+
(nonisolatedAttr ? 1 : 0) + (globalActorAttr ? 1 : 0);
25812575
if (numIsolationAttrs == 0)
25822576
return None;
25832577

@@ -2594,32 +2588,20 @@ static Optional<ActorIsolation> getIsolationFromAttributes(
25942588

25952589
if (globalActorAttr) {
25962590
if (shouldDiagnose) {
2597-
if (globalActorAttr) {
2598-
const DeclAttribute *otherAttr =
2599-
nonisolatedAttr
2600-
? static_cast<const DeclAttribute *>(nonisolatedAttr)
2601-
: distributedActorIndependentAttr;
2602-
decl->diagnose(
2603-
diag::actor_isolation_multiple_attr, decl->getDescriptiveKind(),
2604-
name, otherAttr->getAttrName(),
2605-
globalActorAttr->second->getName().str())
2606-
.highlight(otherAttr->getRangeWithAt())
2607-
.highlight(globalActorAttr->first->getRangeWithAt());
2608-
} else {
2609-
decl->diagnose(
2610-
diag::actor_isolation_multiple_attr, decl->getDescriptiveKind(),
2611-
name, nonisolatedAttr->getAttrName(),
2612-
distributedActorIndependentAttr->getAttrName())
2613-
.highlight(nonisolatedAttr->getRangeWithAt())
2614-
.highlight(distributedActorIndependentAttr->getRangeWithAt());
2591+
decl->diagnose(
2592+
diag::actor_isolation_multiple_attr, decl->getDescriptiveKind(),
2593+
name, nonisolatedAttr->getAttrName(),
2594+
globalActorAttr->second->getName().str())
2595+
.highlight(nonisolatedAttr->getRangeWithAt())
2596+
.highlight(globalActorAttr->first->getRangeWithAt());
26152597
}
26162598
}
26172599
}
26182600
}
26192601

2620-
// If the declaration is explicitly marked 'nonisolated' or distributed
2621-
// actor-independent, report it as nonisolated.
2622-
if (nonisolatedAttr || distributedActorIndependentAttr) {
2602+
// If the declaration is explicitly marked 'nonisolated', report it as
2603+
// independent.
2604+
if (nonisolatedAttr) {
26232605
return ActorIsolation::forIndependent();
26242606
}
26252607

lib/Sema/TypeCheckDeclOverride.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,6 @@ namespace {
15421542
UNINTERESTING_ATTR(OriginallyDefinedIn)
15431543
UNINTERESTING_ATTR(Actor)
15441544
UNINTERESTING_ATTR(DistributedActor)
1545-
UNINTERESTING_ATTR(DistributedActorIndependent)
15461545
UNINTERESTING_ATTR(GlobalActor)
15471546
UNINTERESTING_ATTR(Async)
15481547
UNINTERESTING_ATTR(Sendable)

test/Distributed/distributed_actor_isolation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func test_outside(
134134
_ = distributed.name // expected-error{{distributed actor-isolated property 'name' can only be referenced inside the distributed actor}}
135135
_ = distributed.mutable // expected-error{{distributed actor-isolated property 'mutable' can only be referenced inside the distributed actor}}
136136

137-
// ==== special properties (@_distributedActorIndependent)
137+
// ==== special properties (nonisolated, implicitly replicated)
138138
// the distributed actor's special fields may always be referred to
139139
_ = distributed.id
140140
_ = distributed.actorTransport

0 commit comments

Comments
 (0)