Skip to content

Commit 1011e4d

Browse files
committed
[Concurrency] Only deprecate AnyActor, and update more tests.
Obsoleting `AnyActor` in Swift 6 blocks the Concurrency library itself from migrating to Swift 6, because `Actor` and `DistributedActor` have to preserve their refinement of `AnyActor` to avoid breaking code currently using the marker protocol. There's no way to move protocol refinement into an extension so that the use-site declaration can be obsoleted, so we're stuck with just the deprecation of `AnyActor`.
1 parent 2590b2d commit 1011e4d

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

stdlib/public/Concurrency/Actor.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import Swift
2929
@_marker
3030
@available(SwiftStdlib 5.1, *)
3131
@available(*, deprecated, message: "Use 'any Actor' with 'DistributedActor.asLocalActor' instead")
32-
@available(swift, obsoleted: 6.0, message: "Use 'any Actor' with 'DistributedActor.asLocalActor' instead")
3332
public protocol AnyActor: AnyObject, Sendable {}
3433

3534
/// Common protocol to which all actors conform.

test/Distributed/actor_protocols.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,17 @@ struct S2: DistributedActor {
9393

9494
// ==== -----------------------------------------------------------------------
9595

96-
actor A3: AnyActor {} // ok
97-
distributed actor DA3: AnyActor {} // ok
96+
actor A3: AnyActor {} // expected-warning {{'AnyActor' is deprecated: Use 'any Actor' with 'DistributedActor.asLocalActor' instead}}
97+
distributed actor DA3: AnyActor {} // expected-warning {{'AnyActor' is deprecated: Use 'any Actor' with 'DistributedActor.asLocalActor' instead}}
9898

99-
class C3: AnyActor, @unchecked Sendable {
99+
class C3: AnyActor, @unchecked Sendable { // expected-warning {{'AnyActor' is deprecated: Use 'any Actor' with 'DistributedActor.asLocalActor' instead}}
100100
// expected-error@-1{{non-actor type 'C3' cannot conform to the 'AnyActor' protocol}} {{1-6=actor}}
101101
}
102102

103-
struct S3: AnyActor {
103+
struct S3: AnyActor { // expected-warning {{'AnyActor' is deprecated: Use 'any Actor' with 'DistributedActor.asLocalActor' instead}}
104104
// expected-error@-1{{non-class type 'S3' cannot conform to class protocol 'AnyActor'}}
105105
}
106106

107-
enum E3: AnyActor {
107+
enum E3: AnyActor { // expected-warning {{'AnyActor' is deprecated: Use 'any Actor' with 'DistributedActor.asLocalActor' instead}}
108108
// expected-error@-1{{non-class type 'E3' cannot conform to class protocol 'AnyActor'}}
109109
}

test/decl/protocol/special/DistributedActor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ distributed actor D5: P1 {
6868

6969
// Make sure the conformances have been added implicitly.
7070
func acceptDistributedActor<Act: DistributedActor>(_: Act.Type) { }
71-
func acceptAnyActor<Act: AnyActor>(_: Act.Type) { }
71+
func acceptAnyActor<Act: AnyActor>(_: Act.Type) { } // expected-warning {{'AnyActor' is deprecated: Use 'any Actor' with 'DistributedActor.asLocalActor' instead}}
7272

7373
func testConformance() {
7474
acceptDistributedActor(D1.self)
@@ -86,4 +86,4 @@ distributed actor A: P {
8686
distributed func foo() { }
8787
// expected-error@-1{{actor-isolated distributed instance method 'foo()' cannot be used to satisfy nonisolated protocol requirement}}
8888
}
89-
// ---
89+
// ---

0 commit comments

Comments
 (0)