|
| 1 | +// REQUIRES: swift_swift_parser, asserts |
| 2 | +// |
| 3 | +// UNSUPPORTED: back_deploy_concurrency |
| 4 | +// REQUIRES: concurrency |
| 5 | +// REQUIRES: distributed |
| 6 | +// |
| 7 | +// RUN: %empty-directory(%t) |
| 8 | +// RUN: %empty-directory(%t-scratch) |
| 9 | + |
| 10 | +// RUN: %target-swift-frontend -typecheck -verify -disable-availability-checking -plugin-path %swift-plugin-dir -I %t -dump-macro-expansions %s -dump-macro-expansions 2>&1 | %FileCheck %s |
| 11 | + |
| 12 | +// FIXME: inheritance tests limited because cannot refer to any generated macro from the same module... |
| 13 | +// XFAIL: * |
| 14 | + |
| 15 | +import Distributed |
| 16 | + |
| 17 | +typealias System = LocalTestingDistributedActorSystem |
| 18 | + |
| 19 | +@_DistributedProtocol |
| 20 | +protocol EmptyBase {} |
| 21 | + |
| 22 | +// TODO: allow this? |
| 23 | +//@_DistributedProtocol |
| 24 | +//extension EmptyBase {} |
| 25 | + |
| 26 | +// @_DistributedProtocol -> |
| 27 | +// |
| 28 | +// CHECK: @freestanding(declaration) |
| 29 | +// CHECK: macro _distributed_stubs_EmptyBase() = |
| 30 | +// CHECK: #distributedStubs( |
| 31 | +// CHECK: module: "main", protocolName: "EmptyBase", |
| 32 | +// CHECK: stubProtocols: [] |
| 33 | +// CHECK: ) |
| 34 | +// |
| 35 | +// CHECK: // distributed actor $EmptyBase <ActorSystem>: EmptyBase where SerializationRequirement == any Codable { |
| 36 | +// CHECK: distributed actor $EmptyBase : EmptyBase { |
| 37 | +// CHECK: typealias ActorSystem = LocalTestingDistributedActorSystem // FIXME: remove this |
| 38 | +// |
| 39 | +// CHECK: #distributedStubs( |
| 40 | +// CHECK: module: "main", protocolName: "EmptyBase", |
| 41 | +// CHECK: stubProtocols: [] |
| 42 | +// CHECK: ) |
| 43 | +// CHECK: } |
| 44 | + |
| 45 | +@_DistributedProtocol |
| 46 | +protocol G3: DistributedActor, EmptyBase where SerializationRequirement == any Codable { |
| 47 | + distributed func get() -> String |
| 48 | + distributed func greet(name: String) -> String |
| 49 | +} |
| 50 | + |
| 51 | +// @_DistributedProtocol -> |
| 52 | +// |
| 53 | +// Since we have also the EmptyBase we don't know what names it will introduce, |
| 54 | +// so this stubs macro must be "names: arbitrary": |
| 55 | +// CHECK: @freestanding(declaration, names: arbitrary) |
| 56 | +// CHECK: macro _distributed_stubs_G3() = |
| 57 | +// CHECK: #distributedStubs( |
| 58 | +// CHECK: module: "main", protocolName: "G3", |
| 59 | +// CHECK: stubProtocols: ["EmptyBase"], |
| 60 | +// CHECK: "distributed func get() -> String", |
| 61 | +// CHECK: "distributed func greet(name: String) -> String" |
| 62 | +// CHECK: ) |
| 63 | +// |
| 64 | +// TODO: distributed actor $G3<ActorSystem>: Greeter where SerializationRequirement == any Codable { |
| 65 | +// CHECK: distributed actor $G3: G3, EmptyBase { |
| 66 | +// TODO: Preferably, we could refer to our own macro like this: #_distributed_stubs_G3 |
| 67 | +// WORKAROUND: |
| 68 | +// CHECK: #distributedStubs( |
| 69 | +// CHECK: module: "main", protocolName: "G3", |
| 70 | +// CHECK: stubProtocols: ["EmptyBase"], |
| 71 | +// CHECK: "distributed func get() -> String", |
| 72 | +// CHECK: "distributed func greet(name: String) -> String" |
| 73 | +// CHECK: ) |
| 74 | +// CHECK: |
| 75 | +// FIXME: the below cannot find the macro because it's form the same module |
| 76 | +// CHECK: // stub inherited members |
| 77 | +// CHECK: #_distributed_stubs_EmptyBase |
| 78 | +// CHECK: } |
| 79 | + |
| 80 | +// ==== ------------------------------------------------------------------------ |
0 commit comments