|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/../Inputs/FakeDistributedActorSystems.swift |
| 3 | +// RUN: %target-build-swift -module-name main -Xfrontend -disable-availability-checking -j2 -parse-as-library -I %t %s %S/../Inputs/FakeDistributedActorSystems.swift -o %t/a.out |
| 4 | +// RUN: %target-codesign %t/a.out |
| 5 | +// RUN: %target-run %t/a.out | %FileCheck %s --color |
| 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 | +// UNSUPPORTED: OS=windows-msvc |
| 16 | + |
| 17 | +import Distributed |
| 18 | +import FakeDistributedActorSystems |
| 19 | + |
| 20 | +typealias DefaultDistributedActorSystem = FakeRoundtripActorSystem |
| 21 | + |
| 22 | +struct Outer: Sendable, Codable { |
| 23 | + distributed actor Greeter<Element> where Element: Sendable & Codable { |
| 24 | + distributed func hello() -> String { |
| 25 | + return "Hello, \(Element.self)!" |
| 26 | + } |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +struct OuterGeneric<Element>: Sendable, Codable where Element: Sendable & Codable { |
| 31 | + distributed actor Greeter { |
| 32 | + distributed func hello() -> String { |
| 33 | + return "Hello, \(Element.self)!" |
| 34 | + } |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +func test() async throws { |
| 39 | + let system = DefaultDistributedActorSystem() |
| 40 | + |
| 41 | + do { |
| 42 | + let local = Outer.Greeter<String>(actorSystem: system) |
| 43 | + let ref = try Outer.Greeter<String>.resolve(id: local.id, using: system) |
| 44 | + let response = try await ref.hello() |
| 45 | + // CHECK: > encode generic sub: Swift.String |
| 46 | + // CHECK: >> remoteCall: on:main.Outer.Greeter<Swift.String>, target:Greeter.hello(), invocation:FakeInvocationEncoder(genericSubs: [Swift.String], arguments: [], returnType: Optional(Swift.String), errorType: nil), throwing:Swift.Never, returning:Swift.String |
| 47 | + print("response 1: \(response)") |
| 48 | + // CHECK: response 1: Hello, String! |
| 49 | + } |
| 50 | + |
| 51 | + do { |
| 52 | + let local = OuterGeneric<String>.Greeter(actorSystem: system) |
| 53 | + let ref = try OuterGeneric<String>.Greeter.resolve(id: local.id, using: system) |
| 54 | + let response = try await ref.hello() |
| 55 | + // CHECK: > encode generic sub: Swift.String |
| 56 | + // CHECK: >> remoteCall: on:main.OuterGeneric<Swift.String>.Greeter, target:Greeter.hello(), invocation:FakeInvocationEncoder(genericSubs: [Swift.String], arguments: [], returnType: Optional(Swift.String), errorType: nil), throwing:Swift.Never, returning:Swift.String |
| 57 | + print("response 2: \(response)") |
| 58 | + // CHECK: response 2: Hello, String! |
| 59 | + } |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | +} |
| 64 | + |
| 65 | +@main struct Main { |
| 66 | + static func main() async { |
| 67 | + try! await test() |
| 68 | + } |
| 69 | +} |
0 commit comments