|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -target %target-swift-6.0-abi-triple %S/../Inputs/FakeDistributedActorSystems.swift -plugin-path %swift-plugin-dir |
| 3 | +// RUN: %target-build-swift -module-name ActorsFramework -target %target-swift-6.0-abi-triple -j2 -parse-as-library -I %t %s %S/../Inputs/FakeDistributedActorSystems.swift -plugin-path %swift-plugin-dir -o %t/a.out |
| 4 | +// RUN: %target-codesign %t/a.out |
| 5 | +// RUN: %env-SWIFT_DUMP_ACCESSIBLE_FUNCTIONS=true %target-run %t/a.out 2>&1 | %FileCheck %s --color --dump-input=always |
| 6 | + |
| 7 | +// REQUIRES: executable_test |
| 8 | +// REQUIRES: concurrency |
| 9 | +// REQUIRES: distributed |
| 10 | + |
| 11 | +// rdar://76038845 |
| 12 | +// UNSUPPORTED: use_os_stdlib |
| 13 | +// UNSUPPORTED: back_deployment_runtime |
| 14 | + |
| 15 | +// FIXME(distributed): Distributed actors currently have some issues on windows, isRemote always returns false. rdar://82593574 |
| 16 | +// UNSUPPORTED: OS=windows-msvc |
| 17 | + |
| 18 | +import Distributed |
| 19 | +import FakeDistributedActorSystems |
| 20 | + |
| 21 | +// ==== Known actor system ----------------------------------------------------- |
| 22 | + |
| 23 | +public struct Response: Codable, Sendable { |
| 24 | + let resp: Int |
| 25 | + public init(resp: Int) { |
| 26 | + self.resp = resp |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +public struct Provider: Codable, Sendable { |
| 31 | + let r1: Int |
| 32 | + public init(r1: Int) { |
| 33 | + self.r1 = r1 |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +@Resolvable |
| 38 | +public protocol DistributedNotificationService: DistributedActor |
| 39 | +where ActorSystem == FakeRoundtripActorSystem { |
| 40 | + distributed func getArray(a1: [Int], a2: String?) async throws -> [Response] |
| 41 | +} |
| 42 | + |
| 43 | +distributed actor DistributedNotificationServiceImpl: DistributedNotificationService { |
| 44 | + typealias ActorSystem = FakeRoundtripActorSystem |
| 45 | + |
| 46 | + distributed func getArray(a1: [Int], a2: String?) async throws -> [Response] { |
| 47 | + [] // mock impl is enough |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +// ==== ------------------------------------------------------------------------ |
| 52 | + |
| 53 | +@main struct Main { |
| 54 | + static func main() async throws { |
| 55 | + let roundtripSystem = FakeRoundtripActorSystem() |
| 56 | + |
| 57 | + let real: any DistributedNotificationService = DistributedNotificationServiceImpl( |
| 58 | + actorSystem: roundtripSystem) |
| 59 | + |
| 60 | + let proxy: any DistributedNotificationService = |
| 61 | + try $DistributedNotificationService.resolve(id: real.id, using: roundtripSystem) |
| 62 | + _ = try await proxy.getArray(a1: [], a2: "") |
| 63 | + |
| 64 | + // CHECK: ==== Accessible Function Records ==== |
| 65 | + |
| 66 | + // CHECK: Record name: $s15ActorsFramework30DistributedNotificationServicePAA0C001_C9ActorStubRzrlE8getArray2a12a2SayAA8ResponseVGSaySiG_SSSgtYaKFTE |
| 67 | + // CHECK: Demangled: distributed thunk (extension in ActorsFramework):ActorsFramework.DistributedNotificationService< where A: Distributed._DistributedActorStub>.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<ActorsFramework.Response> |
| 68 | + // CHECK: Function Ptr: [[PTR:0x.*]] |
| 69 | + // CHECK: Flags.IsDistributed: 1 |
| 70 | + |
| 71 | + // CHECK: Record name: $s15ActorsFramework34DistributedNotificationServiceImplC8getArray2a12a2SayAA8ResponseVGSaySiG_SSSgtYaKFTE |
| 72 | + // CHECK: Demangled: distributed thunk ActorsFramework.DistributedNotificationServiceImpl.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<ActorsFramework.Response> |
| 73 | + // CHECK: Function Ptr: [[PTR:0x.*]] |
| 74 | + // CHECK: Flags.IsDistributed: 1 |
| 75 | + |
| 76 | + // CHECK: Record name: $s15ActorsFramework31$DistributedNotificationServiceC8getArray2a12a2SayAA8ResponseVGSaySiG_SSSgtYaKFTE |
| 77 | + // CHECK: Demangled: distributed thunk ActorsFramework.$DistributedNotificationService.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<ActorsFramework.Response> |
| 78 | + // CHECK: Function Ptr: [[PTR:0x.*]] |
| 79 | + // CHECK: Flags.IsDistributed: 1 |
| 80 | + |
| 81 | + // CHECK: Record count: 3 |
| 82 | + // CHECK: ==== End of Accessible Function Records ==== |
| 83 | + } |
| 84 | +} |
0 commit comments