Skip to content

Commit 826b59b

Browse files
authored
Merge pull request #36606 from DougGregor/remove-actor-independent-unsafe-isolation
[Concurrency] Remove actorIndependent(unsafe) isolation.
2 parents bae76c8 + 9d8fde8 commit 826b59b

11 files changed

+8
-294
lines changed

include/swift/AST/ActorIsolation.h

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ class ActorIsolation {
5151
/// meaning that it can be used from any actor but is also unable to
5252
/// refer to the isolated state of any given actor.
5353
Independent,
54-
/// The declaration is explicitly specified to be independent of any actor,
55-
/// but the programmer promises to protect the declaration from concurrent
56-
/// accesses manually. Thus, it is okay if this declaration is a mutable
57-
/// variable that creates storage.
58-
IndependentUnsafe,
5954
/// The declaration is isolated to a global actor. It can refer to other
6055
/// entities with the same global actor.
6156
GlobalActor,
@@ -84,18 +79,8 @@ class ActorIsolation {
8479
return ActorIsolation(Unspecified, nullptr);
8580
}
8681

87-
static ActorIsolation forIndependent(ActorIndependentKind indepKind) {
88-
ActorIsolation::Kind isoKind;
89-
switch (indepKind) {
90-
case ActorIndependentKind::Safe:
91-
isoKind = Independent;
92-
break;
93-
94-
case ActorIndependentKind::Unsafe:
95-
isoKind = IndependentUnsafe;
96-
break;
97-
}
98-
return ActorIsolation(isoKind, nullptr);
82+
static ActorIsolation forIndependent() {
83+
return ActorIsolation(Independent, nullptr);
9984
}
10085

10186
static ActorIsolation forActorInstance(NominalTypeDecl *actor) {
@@ -141,7 +126,6 @@ class ActorIsolation {
141126

142127
switch (lhs.kind) {
143128
case Independent:
144-
case IndependentUnsafe:
145129
case Unspecified:
146130
return true;
147131

include/swift/AST/Attr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(actor, Actor,
580580
DECL_ATTR(actorIndependent, ActorIndependent,
581581
OnClass | OnStruct | OnEnum | OnExtension | OnFunc | OnConstructor |
582582
OnVar | OnSubscript | ConcurrencyOnly |
583-
ABIStableToAdd | ABIStableToRemove |
583+
ABIBreakingToAdd | ABIBreakingToRemove |
584584
APIBreakingToAdd | APIBreakingToRemove,
585585
103)
586586

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8060,7 +8060,7 @@ ActorIsolation swift::getActorIsolationOfContext(DeclContext *dc) {
80608060
if (auto *closure = dyn_cast<AbstractClosureExpr>(dc)) {
80618061
switch (auto isolation = closure->getActorIsolation()) {
80628062
case ClosureActorIsolation::Independent:
8063-
return ActorIsolation::forIndependent(ActorIndependentKind::Safe);
8063+
return ActorIsolation::forIndependent();
80648064

80658065
case ClosureActorIsolation::GlobalActor: {
80668066
return ActorIsolation::forGlobalActor(

lib/AST/DiagnosticEngine.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -706,12 +706,8 @@ static void formatDiagnosticArgument(StringRef Modifier,
706706
Out << "actor-independent";
707707
break;
708708

709-
case ActorIsolation::IndependentUnsafe:
710-
Out << "actor-independent-unsafe";
711-
break;
712-
713709
case ActorIsolation::Unspecified:
714-
Out << "non-actor-isolated";
710+
Out << "unspecified";
715711
break;
716712
}
717713
}

lib/AST/TypeCheckRequests.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,6 @@ bool ActorIsolation::requiresSubstitution() const {
15261526
switch (kind) {
15271527
case ActorInstance:
15281528
case Independent:
1529-
case IndependentUnsafe:
15301529
case Unspecified:
15311530
return false;
15321531

@@ -1541,7 +1540,6 @@ ActorIsolation ActorIsolation::subst(SubstitutionMap subs) const {
15411540
switch (kind) {
15421541
case ActorInstance:
15431542
case Independent:
1544-
case IndependentUnsafe:
15451543
case Unspecified:
15461544
return *this;
15471545

@@ -1564,10 +1562,6 @@ void swift::simple_display(
15641562
out << "actor-independent";
15651563
break;
15661564

1567-
case ActorIsolation::IndependentUnsafe:
1568-
out << "actor-independent (unsafe)";
1569-
break;
1570-
15711565
case ActorIsolation::Unspecified:
15721566
out << "unspecified actor isolation";
15731567
break;

lib/IDE/CodeCompletion.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2535,7 +2535,6 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
25352535
break;
25362536
case ActorIsolation::Unspecified:
25372537
case ActorIsolation::Independent:
2538-
case ActorIsolation::IndependentUnsafe:
25392538
return;
25402539
}
25412540

lib/SILGen/SILGenProlog.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,6 @@ void SILGenFunction::emitProlog(CaptureInfo captureInfo,
473473
switch (actorIsolation.getKind()) {
474474
case ActorIsolation::Unspecified:
475475
case ActorIsolation::Independent:
476-
case ActorIsolation::IndependentUnsafe:
477476
case ActorIsolation::GlobalActorUnsafe:
478477
break;
479478

@@ -566,7 +565,6 @@ ExecutorBreadcrumb SILGenFunction::emitHopToTargetActor(SILLocation loc,
566565
switch (actorIso.getKind()) {
567566
case ActorIsolation::Unspecified:
568567
case ActorIsolation::Independent:
569-
case ActorIsolation::IndependentUnsafe:
570568
break;
571569

572570
case ActorIsolation::ActorInstance: {

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,6 @@ ActorIsolationRestriction ActorIsolationRestriction::forDeclaration(
676676
}
677677

678678
case ActorIsolation::Independent:
679-
case ActorIsolation::IndependentUnsafe:
680679
// Actor-independent have no restrictions on their access.
681680
return forUnrestricted();
682681

@@ -1557,7 +1556,6 @@ namespace {
15571556
switch (auto isolation = getActorIsolationOfContext(dc)) {
15581557
case ActorIsolation::ActorInstance:
15591558
case ActorIsolation::Independent:
1560-
case ActorIsolation::IndependentUnsafe:
15611559
case ActorIsolation::Unspecified:
15621560
return isolation;
15631561

@@ -1733,10 +1731,6 @@ namespace {
17331731
return true;
17341732
}
17351733

1736-
case ActorIsolation::IndependentUnsafe:
1737-
// Allow unrestricted use of something in a global actor.
1738-
return false;
1739-
17401734
case ActorIsolation::Independent: {
17411735
auto result = tryMarkImplicitlyAsync(loc, valueRef, context);
17421736
if (result == AsyncMarkingResult::FoundAsync)
@@ -2107,7 +2101,6 @@ namespace {
21072101

21082102
return false;
21092103

2110-
case ActorIsolation::IndependentUnsafe:
21112104
case ActorIsolation::Unspecified:
21122105
return false;
21132106

@@ -2220,7 +2213,6 @@ namespace {
22202213
// We must have parent isolation determined to get here.
22212214
switch (parentIsolation) {
22222215
case ActorIsolation::Independent:
2223-
case ActorIsolation::IndependentUnsafe:
22242216
case ActorIsolation::Unspecified:
22252217
return ClosureActorIsolation::forIndependent();
22262218

@@ -2372,13 +2364,13 @@ static Optional<ActorIsolation> getIsolationFromAttributes(
23722364
// If the declaration is explicitly marked 'nonisolated', report it as
23732365
// independent.
23742366
if (nonisolatedAttr) {
2375-
return ActorIsolation::forIndependent(ActorIndependentKind::Safe);
2367+
return ActorIsolation::forIndependent();
23762368
}
23772369

23782370
// If the declaration is explicitly marked @actorIndependent, report it as
23792371
// independent.
23802372
if (independentAttr) {
2381-
return ActorIsolation::forIndependent(independentAttr->getKind());
2373+
return ActorIsolation::forIndependent();
23822374
}
23832375

23842376
// If the declaration is marked with a global actor, report it as being
@@ -2446,7 +2438,6 @@ static Optional<ActorIsolation> getIsolationFromWitnessedRequirements(
24462438
case ActorIsolation::GlobalActor:
24472439
case ActorIsolation::GlobalActorUnsafe:
24482440
case ActorIsolation::Independent:
2449-
case ActorIsolation::IndependentUnsafe:
24502441
break;
24512442
}
24522443

@@ -2471,7 +2462,6 @@ static Optional<ActorIsolation> getIsolationFromWitnessedRequirements(
24712462
llvm_unreachable("protocol requirements cannot be actor instances");
24722463

24732464
case ActorIsolation::Independent:
2474-
case ActorIsolation::IndependentUnsafe:
24752465
// We only need one @actorIndependent.
24762466
if (sawActorIndependent)
24772467
return true;
@@ -2533,8 +2523,7 @@ ActorIsolation ActorIsolationRequest::evaluate(
25332523
// A @Sendable function is assumed to be actor-independent.
25342524
if (auto func = dyn_cast<AbstractFunctionDecl>(value)) {
25352525
if (func->isSendable()) {
2536-
defaultIsolation = ActorIsolation::forIndependent(
2537-
ActorIndependentKind::Safe);
2526+
defaultIsolation = ActorIsolation::forIndependent();
25382527
}
25392528
}
25402529

@@ -2553,8 +2542,6 @@ ActorIsolation ActorIsolationRequest::evaluate(
25532542
// inferred, so that (e.g.) it will be printed and serialized.
25542543
ASTContext &ctx = value->getASTContext();
25552544
switch (inferred) {
2556-
// FIXME: if the context is 'unsafe', is it fine to infer the 'safe' one?
2557-
case ActorIsolation::IndependentUnsafe:
25582545
case ActorIsolation::Independent:
25592546
value->getAttrs().add(new (ctx) ActorIndependentAttr(
25602547
ActorIndependentKind::Safe, /*IsImplicit=*/true));
@@ -2727,12 +2714,6 @@ void swift::checkOverrideActorIsolation(ValueDecl *value) {
27272714
if (isolation == overriddenIsolation)
27282715
return;
27292716

2730-
// If the overridden declaration is @actorIndependent(unsafe) and the
2731-
// overriding declaration has been placed in a global actor, allow it.
2732-
if (overriddenIsolation.getKind() == ActorIsolation::IndependentUnsafe &&
2733-
isolation.isGlobalActor())
2734-
return;
2735-
27362717
// If the overridden declaration is from Objective-C with no actor annotation,
27372718
// and the overriding declaration has been placed in a global actor, allow it.
27382719
if (overridden->hasClangNode() && !overriddenIsolation &&
@@ -2744,7 +2725,6 @@ void swift::checkOverrideActorIsolation(ValueDecl *value) {
27442725
if (overriddenIsolation == ActorIsolation::GlobalActorUnsafe) {
27452726
switch (isolation) {
27462727
case ActorIsolation::Independent:
2747-
case ActorIsolation::IndependentUnsafe:
27482728
case ActorIsolation::Unspecified:
27492729
return;
27502730

@@ -2773,7 +2753,6 @@ void swift::checkOverrideActorIsolation(ValueDecl *value) {
27732753

27742754
case ActorIsolation::ActorInstance:
27752755
case ActorIsolation::Independent:
2776-
case ActorIsolation::IndependentUnsafe:
27772756
// Diagnose below.
27782757
break;
27792758

lib/Sema/TypeCheckPropertyWrapper.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ static VarDecl *findValueProperty(ASTContext &ctx, NominalTypeDecl *nominal,
9393
case ActorIsolation::GlobalActor:
9494
case ActorIsolation::GlobalActorUnsafe:
9595
case ActorIsolation::Independent:
96-
case ActorIsolation::IndependentUnsafe:
9796
case ActorIsolation::Unspecified:
9897
break;
9998
}

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,10 +2831,6 @@ bool ConformanceChecker::checkActorIsolation(
28312831
break;
28322832
}
28332833

2834-
case ActorIsolation::IndependentUnsafe:
2835-
// The requirement is explicitly unsafe; allow it.
2836-
return false;
2837-
28382834
case ActorIsolation::Independent:
28392835
case ActorIsolation::Unspecified:
28402836
break;

0 commit comments

Comments
 (0)