Skip to content

Commit 5e78c3b

Browse files
committed
[Distributed] Restore availability macro definitions & update to 5.6
The _Distributed module is being introduced in Swift 5.6, so its definitions need to come with matching availability. (We don't have version numbers for the associated OS releases, so we need to use placeholder 9999 availability for these.)
1 parent 4795690 commit 5e78c3b

20 files changed

+115
-111
lines changed

stdlib/public/Distributed/ActorTransport.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import Swift
1414
import _Concurrency
1515

16-
@available(SwiftStdlib 5.1, *)
16+
@available(SwiftStdlib 5.6, *)
1717
public protocol ActorTransport: Sendable {
1818

1919
// ==== ---------------------------------------------------------------------

stdlib/public/Distributed/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ add_swift_target_library(swift_Distributed ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
3434
${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
3535
-parse-stdlib
3636
-Xfrontend -enable-experimental-distributed
37+
-Xfrontend -define-availability
38+
-Xfrontend "SwiftStdlib 5.1:macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0"
39+
-Xfrontend -define-availability
40+
-Xfrontend "SwiftStdlib 5.6:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999"
3741
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
3842

3943
SWIFT_MODULE_DEPENDS _Concurrency

stdlib/public/Distributed/DistributedActor.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import _Concurrency
2020
///
2121
/// FIXME(distributed): We'd need Actor to also conform to this, but don't want to add that conformance in _Concurrency yet.
2222
@_marker
23-
@available(SwiftStdlib 5.1, *)
23+
@available(SwiftStdlib 5.6, *)
2424
public protocol AnyActor: Sendable, AnyObject {}
2525

2626
// ==== Distributed Actor -----------------------------------------------------
@@ -33,7 +33,7 @@ public protocol AnyActor: Sendable, AnyObject {}
3333
///
3434
/// The 'DistributedActor' protocol provides the core functionality of any
3535
/// distributed actor.
36-
@available(SwiftStdlib 5.1, *)
36+
@available(SwiftStdlib 5.6, *)
3737
public protocol DistributedActor:
3838
AnyActor, Sendable, Identifiable, Hashable, Codable {
3939
/// Resolves the passed in `identity` against the `transport`, returning
@@ -79,7 +79,7 @@ public protocol DistributedActor:
7979

8080
// ==== Hashable conformance ---------------------------------------------------
8181

82-
@available(SwiftStdlib 5.1, *)
82+
@available(SwiftStdlib 5.6, *)
8383
extension DistributedActor {
8484
nonisolated public func hash(into hasher: inout Hasher) {
8585
self.id.hash(into: &hasher)
@@ -93,11 +93,11 @@ extension DistributedActor {
9393
// ==== Codable conformance ----------------------------------------------------
9494

9595
extension CodingUserInfoKey {
96-
@available(SwiftStdlib 5.1, *)
96+
@available(SwiftStdlib 5.6, *)
9797
public static let actorTransportKey = CodingUserInfoKey(rawValue: "$dist_act_transport")!
9898
}
9999

100-
@available(SwiftStdlib 5.1, *)
100+
@available(SwiftStdlib 5.6, *)
101101
extension DistributedActor {
102102
nonisolated public init(from decoder: Decoder) throws {
103103
guard let transport = decoder.userInfo[.actorTransportKey] as? ActorTransport else {
@@ -118,7 +118,7 @@ extension DistributedActor {
118118

119119
// ==== Local actor special handling -------------------------------------------
120120

121-
@available(SwiftStdlib 5.1, *)
121+
@available(SwiftStdlib 5.6, *)
122122
extension DistributedActor {
123123

124124
/// Executes the passed 'body' only when the distributed actor is local instance.
@@ -143,10 +143,10 @@ extension DistributedActor {
143143
/******************************************************************************/
144144

145145
/// Uniquely identifies a distributed actor, and enables sending messages and identifying remote actors.
146-
@available(SwiftStdlib 5.1, *)
146+
@available(SwiftStdlib 5.6, *)
147147
public protocol ActorIdentity: Sendable, Hashable, Codable {}
148148

149-
@available(SwiftStdlib 5.1, *)
149+
@available(SwiftStdlib 5.6, *)
150150
public struct AnyActorIdentity: ActorIdentity, @unchecked Sendable, CustomStringConvertible {
151151
public let underlying: Any
152152
@usableFromInline let _hashInto: (inout Hasher) -> ()
@@ -208,11 +208,11 @@ public struct AnyActorIdentity: ActorIdentity, @unchecked Sendable, CustomString
208208
/******************************************************************************/
209209

210210
/// Error protocol to which errors thrown by any `ActorTransport` should conform.
211-
@available(SwiftStdlib 5.1, *)
211+
@available(SwiftStdlib 5.6, *)
212212
public protocol ActorTransportError: Error {
213213
}
214214

215-
@available(SwiftStdlib 5.1, *)
215+
@available(SwiftStdlib 5.6, *)
216216
public struct DistributedActorCodingError: ActorTransportError {
217217
public let message: String
218218

test/Distributed/Runtime/distributed_actor_decode.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import _Distributed
1111

12-
@available(SwiftStdlib 5.1, *)
12+
@available(SwiftStdlib 5.6, *)
1313
distributed actor DA: CustomStringConvertible {
1414
nonisolated var description: String {
1515
"DA(\(self.id))"
@@ -18,7 +18,7 @@ distributed actor DA: CustomStringConvertible {
1818

1919
// ==== Fake Transport ---------------------------------------------------------
2020

21-
@available(SwiftStdlib 5.1, *)
21+
@available(SwiftStdlib 5.6, *)
2222
struct ActorAddress: ActorIdentity {
2323
let address: String
2424
init(parse address : String) {
@@ -39,7 +39,7 @@ struct ActorAddress: ActorIdentity {
3939
}
4040
}
4141

42-
@available(SwiftStdlib 5.1, *)
42+
@available(SwiftStdlib 5.6, *)
4343
struct FakeTransport: ActorTransport {
4444
func decodeIdentity(from decoder: Decoder) throws -> AnyActorIdentity {
4545
print("FakeTransport.decodeIdentity from:\(decoder)")
@@ -71,7 +71,7 @@ struct FakeTransport: ActorTransport {
7171

7272
// ==== Test Coding ------------------------------------------------------------
7373

74-
@available(SwiftStdlib 5.1, *)
74+
@available(SwiftStdlib 5.6, *)
7575
class TestEncoder: Encoder {
7676
var codingPath: [CodingKey]
7777
var userInfo: [CodingUserInfoKey: Any]
@@ -135,7 +135,7 @@ class TestEncoder: Encoder {
135135
}
136136
}
137137

138-
@available(SwiftStdlib 5.1, *)
138+
@available(SwiftStdlib 5.6, *)
139139
class TestDecoder: Decoder {
140140
let encoder: TestEncoder
141141
let data: String
@@ -190,7 +190,7 @@ class TestDecoder: Decoder {
190190

191191
// ==== Execute ----------------------------------------------------------------
192192

193-
@available(SwiftStdlib 5.1, *)
193+
@available(SwiftStdlib 5.6, *)
194194
func test() {
195195
let transport = FakeTransport()
196196

@@ -210,7 +210,7 @@ func test() {
210210
print("decoded da2: \(da2)")
211211
}
212212

213-
@available(SwiftStdlib 5.1, *)
213+
@available(SwiftStdlib 5.6, *)
214214
@main struct Main {
215215
static func main() async {
216216
test()

test/Distributed/Runtime/distributed_actor_deinit.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@
1212

1313
import _Distributed
1414

15-
@available(SwiftStdlib 5.1, *)
15+
@available(SwiftStdlib 5.6, *)
1616
actor A {}
1717

18-
@available(SwiftStdlib 5.1, *)
18+
@available(SwiftStdlib 5.6, *)
1919
distributed actor DA {
2020
init(transport: ActorTransport) {}
2121
}
2222

23-
@available(SwiftStdlib 5.1, *)
23+
@available(SwiftStdlib 5.6, *)
2424
distributed actor DA_userDefined {
2525
init(transport: ActorTransport) {}
2626

2727
deinit {}
2828
}
2929

30-
@available(SwiftStdlib 5.1, *)
30+
@available(SwiftStdlib 5.6, *)
3131
distributed actor DA_userDefined2 {
3232
init(transport: ActorTransport) {}
3333

@@ -37,7 +37,7 @@ distributed actor DA_userDefined2 {
3737
}
3838
}
3939

40-
@available(SwiftStdlib 5.1, *)
40+
@available(SwiftStdlib 5.6, *)
4141
distributed actor DA_state {
4242
var name = "Hello"
4343
var age = 42
@@ -52,15 +52,15 @@ distributed actor DA_state {
5252

5353
// ==== Fake Transport ---------------------------------------------------------
5454

55-
@available(SwiftStdlib 5.1, *)
55+
@available(SwiftStdlib 5.6, *)
5656
struct ActorAddress: ActorIdentity {
5757
let address: String
5858
init(parse address : String) {
5959
self.address = address
6060
}
6161
}
6262

63-
@available(SwiftStdlib 5.1, *)
63+
@available(SwiftStdlib 5.6, *)
6464
final class FakeTransport: @unchecked Sendable, ActorTransport {
6565

6666
var n = 0
@@ -95,7 +95,7 @@ final class FakeTransport: @unchecked Sendable, ActorTransport {
9595

9696
// ==== Execute ----------------------------------------------------------------
9797

98-
@available(SwiftStdlib 5.1, *)
98+
@available(SwiftStdlib 5.6, *)
9999
func test() {
100100
let transport = FakeTransport()
101101

@@ -147,7 +147,7 @@ func test() {
147147
// CHECK-NEXT: Deinitializing
148148
}
149149

150-
@available(SwiftStdlib 5.1, *)
150+
@available(SwiftStdlib 5.6, *)
151151
@main struct Main {
152152
static func main() async {
153153
test()

test/Distributed/Runtime/distributed_actor_init_local.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@ enum MyError: Error {
2020
case test
2121
}
2222

23-
@available(SwiftStdlib 5.1, *)
23+
@available(SwiftStdlib 5.6, *)
2424
distributed actor PickATransport1 {
2525
init(kappa transport: ActorTransport, other: Int) {}
2626
}
2727

28-
@available(SwiftStdlib 5.1, *)
28+
@available(SwiftStdlib 5.6, *)
2929
distributed actor PickATransport2 {
3030
init(other: Int, theTransport: ActorTransport) async {}
3131
}
3232

33-
@available(SwiftStdlib 5.1, *)
33+
@available(SwiftStdlib 5.6, *)
3434
distributed actor LocalWorker {
3535
init(transport: ActorTransport) {}
3636
}
3737

38-
@available(SwiftStdlib 5.1, *)
38+
@available(SwiftStdlib 5.6, *)
3939
distributed actor Bug_CallsReadyTwice {
4040
var x: Int
4141
init(transport: ActorTransport, wantBug: Bool) async {
@@ -46,7 +46,7 @@ distributed actor Bug_CallsReadyTwice {
4646
}
4747
}
4848

49-
@available(SwiftStdlib 5.1, *)
49+
@available(SwiftStdlib 5.6, *)
5050
distributed actor Throwy {
5151
init(transport: ActorTransport, doThrow: Bool) throws {
5252
if doThrow {
@@ -55,7 +55,7 @@ distributed actor Throwy {
5555
}
5656
}
5757

58-
@available(SwiftStdlib 5.1, *)
58+
@available(SwiftStdlib 5.6, *)
5959
distributed actor ThrowBeforeFullyInit {
6060
var x: Int
6161
init(transport: ActorTransport, doThrow: Bool) throws {
@@ -68,7 +68,7 @@ distributed actor ThrowBeforeFullyInit {
6868

6969
// ==== Fake Transport ---------------------------------------------------------
7070

71-
@available(SwiftStdlib 5.1, *)
71+
@available(SwiftStdlib 5.6, *)
7272
struct ActorAddress: ActorIdentity {
7373
let address: String
7474
init(parse address: String) {
@@ -79,7 +79,7 @@ struct ActorAddress: ActorIdentity {
7979
// global to track available IDs
8080
var nextID: Int = 1
8181

82-
@available(SwiftStdlib 5.1, *)
82+
@available(SwiftStdlib 5.6, *)
8383
struct FakeTransport: ActorTransport {
8484
func decodeIdentity(from decoder: Decoder) throws -> AnyActorIdentity {
8585
fatalError("not implemented:\(#function)")
@@ -109,7 +109,7 @@ struct FakeTransport: ActorTransport {
109109

110110
// ==== Execute ----------------------------------------------------------------
111111

112-
@available(SwiftStdlib 5.1, *)
112+
@available(SwiftStdlib 5.6, *)
113113
func test() async {
114114
let transport = FakeTransport()
115115

@@ -156,7 +156,7 @@ func test() async {
156156
// CHECK-DAG: resign id:AnyActorIdentity(ActorAddress(address: "[[ID7]]"))
157157
}
158158

159-
@available(SwiftStdlib 5.1, *)
159+
@available(SwiftStdlib 5.6, *)
160160
@main struct Main {
161161
static func main() async {
162162
await test()

test/Distributed/Runtime/distributed_actor_isRemote.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
import _Distributed
1515

16-
@available(SwiftStdlib 5.1, *)
16+
@available(SwiftStdlib 5.6, *)
1717
distributed actor SomeSpecificDistributedActor {
1818
distributed func hello() async throws -> String {
1919
"local impl"
2020
}
2121
}
2222

23-
@available(SwiftStdlib 5.1, *)
23+
@available(SwiftStdlib 5.6, *)
2424
extension SomeSpecificDistributedActor {
2525

2626
@_dynamicReplacement(for: _remote_hello())
@@ -31,25 +31,25 @@ extension SomeSpecificDistributedActor {
3131

3232
// ==== Fake Transport ---------------------------------------------------------
3333

34-
@available(SwiftStdlib 5.1, *)
34+
@available(SwiftStdlib 5.6, *)
3535
struct FakeActorID: ActorIdentity {
3636
let id: UInt64
3737
}
3838

39-
@available(SwiftStdlib 5.1, *)
39+
@available(SwiftStdlib 5.6, *)
4040
enum FakeTransportError: ActorTransportError {
4141
case unsupportedActorIdentity(AnyActorIdentity)
4242
}
4343

44-
@available(SwiftStdlib 5.1, *)
44+
@available(SwiftStdlib 5.6, *)
4545
struct ActorAddress: ActorIdentity {
4646
let address: String
4747
init(parse address : String) {
4848
self.address = address
4949
}
5050
}
5151

52-
@available(SwiftStdlib 5.1, *)
52+
@available(SwiftStdlib 5.6, *)
5353
struct FakeTransport: ActorTransport {
5454
func decodeIdentity(from decoder: Decoder) throws -> AnyActorIdentity {
5555
fatalError("not implemented:\(#function)")
@@ -88,7 +88,7 @@ func __isLocalActor(_ actor: AnyObject) -> Bool {
8888

8989
// ==== Execute ----------------------------------------------------------------
9090

91-
@available(SwiftStdlib 5.1, *)
91+
@available(SwiftStdlib 5.6, *)
9292
func test_remote() async {
9393
let address = ActorAddress(parse: "sact://127.0.0.1/example#1234")
9494
let transport = FakeTransport()
@@ -113,7 +113,7 @@ func test_remote() async {
113113
print("done") // CHECK: done
114114
}
115115

116-
@available(SwiftStdlib 5.1, *)
116+
@available(SwiftStdlib 5.6, *)
117117
@main struct Main {
118118
static func main() async {
119119
await test_remote()

0 commit comments

Comments
 (0)