Skip to content

Commit f581eb7

Browse files
committed
[Concurrency] Remove remaining special cases of ActorIsolation::GlobalActorUnsafe.
1 parent ecd94e4 commit f581eb7

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

lib/AST/Decl.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,15 +2512,21 @@ static bool deferMatchesEnclosingAccess(const FuncDecl *defer) {
25122512
if (type->isAnyActor())
25132513
return true;
25142514

2515-
switch (getActorIsolation(type)) {
2515+
auto isolation = getActorIsolation(type);
2516+
switch (isolation) {
25162517
case ActorIsolation::Unspecified:
25172518
case ActorIsolation::NonisolatedUnsafe:
2518-
case ActorIsolation::GlobalActorUnsafe:
25192519
break;
25202520

2521+
case ActorIsolation::GlobalActorUnsafe:
2522+
case ActorIsolation::GlobalActor:
2523+
if (isolation.preconcurrency())
2524+
break;
2525+
2526+
return true;
2527+
25212528
case ActorIsolation::ActorInstance:
25222529
case ActorIsolation::Nonisolated:
2523-
case ActorIsolation::GlobalActor:
25242530
return true;
25252531
}
25262532
}

lib/AST/TypeCheckRequests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,9 @@ ActorIsolation ActorIsolation::subst(SubstitutionMap subs) const {
16871687

16881688
void swift::simple_display(
16891689
llvm::raw_ostream &out, const ActorIsolation &state) {
1690+
if (state.preconcurrency())
1691+
out << "preconcurrency ";
1692+
16901693
switch (state) {
16911694
case ActorIsolation::ActorInstance:
16921695
out << "actor-isolated to instance of ";
@@ -1721,9 +1724,6 @@ void swift::simple_display(
17211724
} else {
17221725
out << state.getGlobalActor().getString();
17231726
}
1724-
1725-
if (state == ActorIsolation::GlobalActorUnsafe)
1726-
out << "(unsafe)";
17271727
break;
17281728
}
17291729
}

lib/IDE/CompletionLookup.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -768,14 +768,15 @@ void CompletionLookup::analyzeActorIsolation(
768768
break;
769769
}
770770
case ActorIsolation::GlobalActorUnsafe:
771-
// For "unsafe" global actor isolation, automatic 'async' only happens
771+
case ActorIsolation::GlobalActor: {
772+
// For "preconcurrency" global actor isolation, automatic 'async' only happens
772773
// if the context has adopted concurrency.
773-
if (!CanCurrDeclContextHandleAsync &&
774+
if (isolation.preconcurrency() &&
775+
!CanCurrDeclContextHandleAsync &&
774776
!completionContextUsesConcurrencyFeatures(CurrDeclContext)) {
775777
return;
776778
}
777-
LLVM_FALLTHROUGH;
778-
case ActorIsolation::GlobalActor: {
779+
779780
auto getClosureActorIsolation = [this](AbstractClosureExpr *CE) {
780781
// Prefer solution-specific actor-isolations and fall back to the one
781782
// recorded in the AST.

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4863,8 +4863,6 @@ ActorIsolation ActorIsolationRequest::evaluate(
48634863
TypeExpr::createImplicit(inferred.getGlobalActor(), ctx);
48644864
auto attr =
48654865
CustomAttr::create(ctx, SourceLoc(), typeExpr, /*implicit=*/true);
4866-
if (inferred == ActorIsolation::GlobalActorUnsafe)
4867-
attr->setArgIsUnsafe(true);
48684866
value->getAttrs().add(attr);
48694867

48704868
if (inferred.preconcurrency()) {

lib/Serialization/Deserialization.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3863,8 +3863,9 @@ class DeclDeserializer {
38633863

38643864
case ActorIsolation::GlobalActor:
38653865
case ActorIsolation::GlobalActorUnsafe:
3866-
isolation = ActorIsolation::forGlobalActor(globalActor)
3867-
.withPreconcurrency(isoKind == ActorIsolation::GlobalActorUnsafe);
3866+
// 'unsafe' or 'preconcurrency' doesn't mean anything for isolated
3867+
// default arguments.
3868+
isolation = ActorIsolation::forGlobalActor(globalActor);
38683869
break;
38693870

38703871
case ActorIsolation::ActorInstance:

0 commit comments

Comments
 (0)