@@ -20,6 +20,7 @@ import FakeDistributedActorSystems
2020
2121typealias DefaultDistributedActorSystem = FakeRoundtripActorSystem
2222
23+ @available ( SwiftStdlib 6 . 0 , * )
2324protocol PlainWorker {
2425 associatedtype WorkItem : Sendable & Codable
2526 associatedtype WorkResult : Sendable & Codable
@@ -28,7 +29,9 @@ protocol PlainWorker {
2829 func asyncThrows( work: WorkItem ) async throws -> WorkResult
2930}
3031
31- protocol DistributedWorker : DistributedActor where ActorSystem == DefaultDistributedActorSystem {
32+ @Resolvable
33+ @available ( SwiftStdlib 6 . 0 , * )
34+ protocol DistributedWorker < WorkItem, WorkResult> : DistributedActor where ActorSystem == DefaultDistributedActorSystem {
3235 associatedtype WorkItem : Sendable & Codable
3336 associatedtype WorkResult : Sendable & Codable
3437
@@ -49,6 +52,7 @@ protocol DistributedWorker: DistributedActor where ActorSystem == DefaultDistrib
4952 func asyncThrowsReq_witnessDistributed_asyncThrows( work: WorkItem ) async throws -> WorkResult
5053}
5154
55+ @available ( SwiftStdlib 6 . 0 , * )
5256distributed actor ThePlainWorker : PlainWorker {
5357 typealias ActorSystem = DefaultDistributedActorSystem
5458 typealias WorkItem = String
@@ -59,6 +63,7 @@ distributed actor ThePlainWorker: PlainWorker {
5963 }
6064}
6165
66+ @available ( SwiftStdlib 6 . 0 , * )
6267distributed actor TheWorker : DistributedWorker {
6368 typealias ActorSystem = DefaultDistributedActorSystem
6469 typealias WorkItem = String
@@ -105,6 +110,7 @@ distributed actor TheWorker: DistributedWorker {
105110
106111}
107112
113+ @available ( SwiftStdlib 6 . 0 , * )
108114func test_generic( system: DefaultDistributedActorSystem ) async throws {
109115 let localW = TheWorker ( actorSystem: system)
110116 let remoteW = try ! TheWorker . resolve ( id: localW. id, using: system)
@@ -218,6 +224,7 @@ func test_generic(system: DefaultDistributedActorSystem) async throws {
218224 // distributedness of those witnesses never actually is used remotely, but at
219225 // least check we invoke the right methods.
220226
227+ @available ( SwiftStdlib 6 . 0 , * )
221228 func call_requirement_witnessedByDistributed_sync< W: DistributedWorker > ( w: W ) async throws -> String where W. WorkItem == String , W. WorkResult == String {
222229 try await w. whenLocal { __secretlyKnownToBeLocal in
223230 try await __secretlyKnownToBeLocal. asyncThrowsReq_witnessDistributed_sync ( work: " Hello " )
@@ -231,6 +238,7 @@ func test_generic(system: DefaultDistributedActorSystem) async throws {
231238 }
232239 print ( " ==== ---------------------------------------------------------------- " )
233240
241+ @available ( SwiftStdlib 6 . 0 , * )
234242 func call_requirement_witnessedByDistributed_async< W: DistributedWorker > ( w: W ) async throws -> String where W. WorkItem == String , W. WorkResult == String {
235243 try await w. whenLocal { __secretlyKnownToBeLocal in
236244 try await __secretlyKnownToBeLocal. asyncThrowsReq_witnessDistributed_async ( work: " Hello " )
@@ -244,6 +252,7 @@ func test_generic(system: DefaultDistributedActorSystem) async throws {
244252 }
245253 print ( " ==== ---------------------------------------------------------------- " )
246254
255+ @available ( SwiftStdlib 6 . 0 , * )
247256 func call_requirement_witnessedByDistributed_syncThrows< W: DistributedWorker > ( w: W ) async throws -> String where W. WorkItem == String , W. WorkResult == String {
248257 try await w. whenLocal { __secretlyKnownToBeLocal in
249258 try await __secretlyKnownToBeLocal. asyncThrowsReq_witnessDistributed_syncThrows ( work: " Hello " )
@@ -257,6 +266,7 @@ func test_generic(system: DefaultDistributedActorSystem) async throws {
257266 }
258267 print ( " ==== ---------------------------------------------------------------- " )
259268
269+ @available ( SwiftStdlib 6 . 0 , * )
260270 func call_requirement_witnessedByDistributed_asyncThrows< W: DistributedWorker > ( w: W ) async throws -> String where W. WorkItem == String , W. WorkResult == String {
261271 try await w. whenLocal { __secretlyKnownToBeLocal in
262272 try await __secretlyKnownToBeLocal. asyncThrowsReq_witnessDistributed_asyncThrows ( work: " Hello " )
@@ -271,6 +281,7 @@ func test_generic(system: DefaultDistributedActorSystem) async throws {
271281 print ( " ==== ---------------------------------------------------------------- " )
272282}
273283
284+ @available ( SwiftStdlib 6 . 0 , * )
274285func test_whenLocal( system: DefaultDistributedActorSystem ) async throws {
275286 let localW = TheWorker ( actorSystem: system)
276287 let remoteW = try ! TheWorker . resolve ( id: localW. id, using: system)
@@ -341,6 +352,7 @@ func test_whenLocal(system: DefaultDistributedActorSystem) async throws {
341352 }
342353}
343354
355+ @available ( SwiftStdlib 6 . 0 , * )
344356func test_generic_plain( system: DefaultDistributedActorSystem ) async throws {
345357 let localW = ThePlainWorker ( actorSystem: system)
346358 let remoteW = try ! ThePlainWorker . resolve ( id: localW. id, using: system)
@@ -355,6 +367,7 @@ func test_generic_plain(system: DefaultDistributedActorSystem) async throws {
355367 }
356368 print ( " ==== ---------------------------------------------------------------- " )
357369
370+ @available ( SwiftStdlib 6 . 0 , * )
358371 func call_plainWorker< W: PlainWorker > ( w: W ) async throws -> String where W. WorkItem == String , W. WorkResult == String {
359372 try await w. asyncThrows ( work: " Hello " )
360373 }
@@ -372,6 +385,7 @@ func test_generic_plain(system: DefaultDistributedActorSystem) async throws {
372385 }
373386}
374387
388+ @available ( SwiftStdlib 6 . 0 , * )
375389@main struct Main {
376390 static func main( ) async {
377391 let system = DefaultDistributedActorSystem ( )
0 commit comments