Skip to content

Commit e85beea

Browse files
authored
Merge pull request swiftlang#74011 from hborla/6.0-deprecate-anyactor
[6.0][Concurrency] Deprecate `AnyActor`.
2 parents 79cf063 + e1e1c06 commit e85beea

File tree

17 files changed

+37
-60
lines changed

17 files changed

+37
-60
lines changed

include/swift/AST/KnownProtocols.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME(name, "_" #name)
7878

7979
PROTOCOL(Actor)
80-
PROTOCOL(AnyActor)
8180
PROTOCOL(Sequence)
8281
PROTOCOL(Identifiable)
8382
PROTOCOL(IteratorProtocol)

lib/AST/ASTContext.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,6 @@ ProtocolDecl *ASTContext::getProtocol(KnownProtocolKind kind) const {
13071307
M = getLoadedModule(Id_Differentiation);
13081308
break;
13091309
case KnownProtocolKind::Actor:
1310-
case KnownProtocolKind::AnyActor:
13111310
case KnownProtocolKind::GlobalActor:
13121311
case KnownProtocolKind::AsyncSequence:
13131312
case KnownProtocolKind::AsyncIteratorProtocol:

lib/IRGen/GenMeta.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6741,7 +6741,6 @@ SpecialProtocol irgen::getSpecialProtocolID(ProtocolDecl *P) {
67416741
case KnownProtocolKind::Differentiable:
67426742
case KnownProtocolKind::FloatingPoint:
67436743
case KnownProtocolKind::Identifiable:
6744-
case KnownProtocolKind::AnyActor:
67456744
case KnownProtocolKind::Actor:
67466745
case KnownProtocolKind::DistributedActor:
67476746
case KnownProtocolKind::DistributedActorSystem:

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7007,10 +7007,10 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
70077007
auto genericSig = FTy->getInvocationGenericSignature();
70087008
auto &ctx = F.getASTContext();
70097009
auto *actorProtocol = ctx.getProtocol(KnownProtocolKind::Actor);
7010-
auto *anyActorProtocol = ctx.getProtocol(KnownProtocolKind::AnyActor);
7010+
auto *distributedProtocol = ctx.getProtocol(KnownProtocolKind::DistributedActor);
70117011
require(argType->isAnyActorType() ||
7012-
genericSig->requiresProtocol(argType, actorProtocol) ||
7013-
genericSig->requiresProtocol(argType, anyActorProtocol),
7012+
genericSig->requiresProtocol(argType, actorProtocol) ||
7013+
genericSig->requiresProtocol(argType, distributedProtocol),
70147014
"Only any actor types can be isolated");
70157015
require(!foundIsolatedParameter, "Two isolated parameters");
70167016
foundIsolatedParameter = true;

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ static void checkInheritanceClause(
317317
continue;
318318

319319
// AnyObject is not allowed except on protocols.
320-
if (layout.hasExplicitAnyObject) {
320+
if (layout.hasExplicitAnyObject && !isa<ClassDecl>(decl)) {
321321
decl->diagnose(diag::inheritance_from_anyobject);
322322
continue;
323323
}

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6108,19 +6108,6 @@ void TypeChecker::checkConformancesInContext(IterableDeclContext *idc) {
61086108
}
61096109
break;
61106110
}
6111-
case KnownProtocolKind::AnyActor: {
6112-
if (auto classDecl = dyn_cast<ClassDecl>(nominal)) {
6113-
if (!classDecl->isExplicitActor() &&
6114-
!classDecl->isExplicitDistributedActor()) {
6115-
dc->getSelfNominalTypeDecl()
6116-
->diagnose(diag::actor_protocol_illegal_inheritance,
6117-
dc->getSelfNominalTypeDecl()->getName(),
6118-
proto->getName())
6119-
.fixItReplace(nominal->getStartLoc(), "actor");
6120-
}
6121-
}
6122-
break;
6123-
}
61246111
case KnownProtocolKind::UnsafeSendable: {
61256112
hasDeprecatedUnsafeSendable = true;
61266113
break;

stdlib/public/Concurrency/Actor.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@ import Swift
2626
/// While both local and distributed actors are conceptually "actors", there are
2727
/// some important isolation model differences between the two, which make it
2828
/// impossible for one to refine the other.
29-
@_marker
3029
@available(SwiftStdlib 5.1, *)
31-
public protocol AnyActor: AnyObject, Sendable {}
30+
@available(*, deprecated, message: "Use 'any Actor' with 'DistributedActor.asLocalActor' instead")
31+
@available(swift, obsoleted: 6.0, message: "Use 'any Actor' with 'DistributedActor.asLocalActor' instead")
32+
public typealias AnyActor = AnyObject & Sendable
3233

3334
/// Common protocol to which all actors conform.
3435
///
3536
/// The `Actor` protocol generalizes over all `actor` types. Actor types
3637
/// implicitly conform to this protocol.
3738
@available(SwiftStdlib 5.1, *)
38-
public protocol Actor: AnyActor {
39+
public protocol Actor: AnyObject, Sendable {
3940

4041
/// Retrieve the executor for this actor as an optimized, unowned
4142
/// reference.

stdlib/public/Distributed/DistributedActor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ import _Concurrency
197197
/// - SeeAlso: ``Actor``
198198
/// - SeeAlso: ``AnyActor``
199199
@available(SwiftStdlib 5.7, *)
200-
public protocol DistributedActor: AnyActor, Identifiable, Hashable
200+
public protocol DistributedActor: AnyObject, Sendable, Identifiable, Hashable
201201
where ID == ActorSystem.ActorID,
202202
SerializationRequirement == ActorSystem.SerializationRequirement {
203203

stdlib/public/core/Sendable.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,14 @@
147147
///
148148
/// struct MyStructure: @unchecked Sendable { ... }
149149
@available(*, deprecated, message: "Use @unchecked Sendable instead")
150+
@available(swift, obsoleted: 6.0, message: "Use @unchecked Sendable instead")
150151
@_marker public protocol UnsafeSendable: Sendable { }
151152

152153
// Historical names
153154
@available(*, deprecated, renamed: "Sendable")
155+
@available(swift, obsoleted: 6.0, renamed: "Sendable")
154156
public typealias ConcurrentValue = Sendable
155157

156158
@available(*, deprecated, renamed: "Sendable")
159+
@available(swift, obsoleted: 6.0, renamed: "Sendable")
157160
public typealias UnsafeConcurrentValue = UnsafeSendable

test/Concurrency/actor_isolation.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,8 +1079,7 @@ actor A: Actor { // ok
10791079
@available(SwiftStdlib 5.1, *)
10801080
class C: Actor, UnsafeSendable {
10811081
// expected-error@-1{{non-actor type 'C' cannot conform to the 'Actor' protocol}}
1082-
// expected-error@-2{{non-actor type 'C' cannot conform to the 'AnyActor' protocol}}
1083-
// expected-warning@-3{{'UnsafeSendable' is deprecated: Use @unchecked Sendable instead}}
1082+
// expected-warning@-2{{'UnsafeSendable' is deprecated: Use @unchecked Sendable instead}}
10841083
nonisolated var unownedExecutor: UnownedSerialExecutor {
10851084
fatalError()
10861085
}

0 commit comments

Comments
 (0)