Skip to content

Commit a629fed

Browse files
committed
[Distributed][CustomRuntimeAttrs] Add distributed actor test cases
Making sure we can use custom runtime attributes on a `distributed actor` even if only on distributed methods. It seems we can't do this on non distributed methods, as the call is made cross actor so the distributed isolation prevents it. Not sure if that should be possible anyway -- as long as distributed funcs can be annotated the most important part works <3
1 parent a81b0b6 commit a629fed

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/type/runtime_discoverable_attrs.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// REQUIRES: asserts
66

77
import RuntimeAttrs
8+
import Distributed
89

910
@runtimeMetadata
1011
struct Flag<T> {
@@ -305,6 +306,35 @@ extension InvalidConformanceTest2 : Flagged & EnumFlagged {}
305306
// expected-note@-3 {{protocol 'Flagged' requires reflection metadata attribute @Flag}}
306307
// expected-note@-4 {{protocol 'EnumFlagged' requires reflection metadata attribute @EnumFlag}}
307308

309+
typealias DefaultDistributedActorSystem = LocalTestingDistributedActorSystem
310+
311+
distributed actor TestDistributedActor {
312+
@FlagForAsyncFuncs distributed func asyncExternallyDist() throws {}
313+
314+
@FlagForAsyncFuncs distributed func doSomethingDist() async throws {}
315+
316+
@FlagForAsyncFuncs nonisolated func doSomethingNonisolated(_: Int) async {}
317+
318+
@FlagForAsyncFuncs distributed func doSomethingDist(_: Int, x: [Int]) async {}
319+
}
320+
321+
@ActorFlag
322+
distributed actor TestDistributedActor2 {}
323+
324+
@runtimeMetadata
325+
enum ActorFlag<A> {
326+
case actor(A.Type)
327+
case distributedActor(A.Type)
328+
}
329+
330+
extension ActorFlag where A: Actor {
331+
init(attachedTo: A.Type) { self = .actor(attachedTo) }
332+
}
333+
extension ActorFlag where A: DistributedActor {
334+
init(attachedTo: A.Type) { self = .distributedActor(attachedTo) }
335+
}
336+
337+
308338
@Flag
309339
struct ValidConformance1 {}
310340
extension ValidConformance1 : Flagged {} // Ok

0 commit comments

Comments
 (0)