1
- // RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-distributed -parse-as-library) | %FileCheck %s --dump-input=always
1
+ // RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking -Xfrontend - enable-experimental-distributed -parse-as-library) | %FileCheck %s --dump-input=always
2
2
3
3
// REQUIRES: executable_test
4
4
// REQUIRES: concurrency
@@ -41,6 +41,31 @@ distributed actor SomeSpecificDistributedActor {
41
41
" local( \( #function) ) "
42
42
}
43
43
44
+ distributed func callTaskSelf_inner( ) async throws -> String {
45
+ " local( \( #function) ) "
46
+ }
47
+ distributed func callTaskSelf( ) async -> String {
48
+ do {
49
+ return try await Task {
50
+ let called = try await callTaskSelf_inner ( ) // shouldn't use the distributed thunk!
51
+ return " local( \( #function) ) -> \( called) "
52
+ } . value
53
+ } catch {
54
+ return " WRONG local( \( #function) ) thrown( \( error) ) "
55
+ }
56
+ }
57
+
58
+ distributed func callDetachedSelf( ) async -> String {
59
+ do {
60
+ return try await Task . detached {
61
+ let called = try await self . callTaskSelf_inner ( ) // shouldn't use the distributed thunk!
62
+ return " local( \( #function) ) -> \( called) "
63
+ } . value
64
+ } catch {
65
+ return " WRONG local( \( #function) ) thrown( \( error) ) "
66
+ }
67
+ }
68
+
44
69
// === errors
45
70
46
71
distributed func helloThrowsImplBoom( ) throws -> String {
@@ -74,6 +99,21 @@ extension SomeSpecificDistributedActor {
74
99
" remote( \( #function) ) "
75
100
}
76
101
102
+ @_dynamicReplacement ( for: _remote_callTaskSelf ( ) )
103
+ nonisolated func _remote_impl_callTaskSelf( ) async throws -> String {
104
+ " remote( \( #function) ) "
105
+ }
106
+
107
+ @_dynamicReplacement ( for: _remote_callDetachedSelf ( ) )
108
+ nonisolated func _remote_impl_callDetachedSelf( ) async throws -> String {
109
+ " remote( \( #function) ) "
110
+ }
111
+
112
+ @_dynamicReplacement ( for: _remote_callTaskSelf_inner ( ) )
113
+ nonisolated func _remote_impl_callTaskSelf_inner( ) async throws -> String {
114
+ " remote( \( #function) ) "
115
+ }
116
+
77
117
// === errors
78
118
79
119
@_dynamicReplacement ( for: _remote_helloThrowsImplBoom ( ) )
@@ -101,9 +141,6 @@ func __isLocalActor(_ actor: AnyObject) -> Bool {
101
141
@available ( SwiftStdlib 5 . 5 , * )
102
142
struct ActorAddress : ActorIdentity {
103
143
let address : String
104
- init ( parse address : String ) {
105
- self . address = address
106
- }
107
144
}
108
145
109
146
@available ( SwiftStdlib 5 . 5 , * )
@@ -120,7 +157,7 @@ struct FakeTransport: ActorTransport {
120
157
121
158
func assignIdentity< Act> ( _ actorType: Act . Type ) -> AnyActorIdentity
122
159
where Act: DistributedActor {
123
- . init( ActorAddress ( parse : " " ) )
160
+ . init( ActorAddress ( address : " " ) )
124
161
}
125
162
126
163
func actorReady< Act> ( _ actor : Act ) where Act: DistributedActor {
@@ -149,6 +186,12 @@ func test_remote_invoke(address: ActorAddress, transport: ActorTransport) async
149
186
let h4 = try ! await actor . hello ( )
150
187
print ( " \( personality) - hello: \( h4) " )
151
188
189
+ let h5 = try ! await actor . callTaskSelf ( )
190
+ print ( " \( personality) - callTaskSelf: \( h5) " )
191
+
192
+ let h6 = try ! await actor . callDetachedSelf ( )
193
+ print ( " \( personality) - callDetachedSelf: \( h6) " )
194
+
152
195
// error throws
153
196
if __isRemoteActor ( actor ) {
154
197
do {
@@ -180,6 +223,8 @@ func test_remote_invoke(address: ActorAddress, transport: ActorTransport) async
180
223
// CHECK: local - helloAsync: local(helloAsync())
181
224
// CHECK: local - helloThrows: local(helloThrows())
182
225
// CHECK: local - hello: local(hello())
226
+ // CHECK: local - callTaskSelf: local(callTaskSelf()) -> local(callTaskSelf_inner())
227
+ // CHECK: local - callDetachedSelf: local(callDetachedSelf()) -> local(callTaskSelf_inner())
183
228
// CHECK: local - helloThrowsImplBoom: Boom(whoFailed: "impl")
184
229
185
230
print ( " remote isRemote: \( __isRemoteActor ( remote) ) " )
@@ -189,6 +234,8 @@ func test_remote_invoke(address: ActorAddress, transport: ActorTransport) async
189
234
// CHECK: remote - helloAsync: remote(_remote_impl_helloAsync())
190
235
// CHECK: remote - helloThrows: remote(_remote_impl_helloThrows())
191
236
// CHECK: remote - hello: remote(_remote_impl_hello())
237
+ // CHECK: remote - callTaskSelf: remote(_remote_impl_callTaskSelf())
238
+ // CHECK: remote - callDetachedSelf: remote(_remote_impl_callDetachedSelf())
192
239
// CHECK: remote - helloThrowsTransportBoom: Boom(whoFailed: "transport")
193
240
194
241
print ( local)
@@ -198,7 +245,7 @@ func test_remote_invoke(address: ActorAddress, transport: ActorTransport) async
198
245
@available ( SwiftStdlib 5 . 5 , * )
199
246
@main struct Main {
200
247
static func main( ) async {
201
- let address = ActorAddress ( parse : " " )
248
+ let address = ActorAddress ( address : " " )
202
249
let transport = FakeTransport ( )
203
250
204
251
await test_remote_invoke ( address: address, transport: transport)
0 commit comments