1+ // RUN: %empty-directory(%t)
2+ // RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeCodableForDistributedTests.swiftmodule -module-name FakeCodableForDistributedTests -disable-availability-checking %S/../Inputs/FakeCodableForDistributedTests.swift
3+ // RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/../Inputs/FakeDistributedActorSystems.swift
4+ // XXX: %target-build-swift -emit-silgen -module-name main -Xfrontend -enable-experimental-distributed -Xfrontend -disable-availability-checking -j2 -parse-as-library -I %t %s %S/../Inputs/FakeCodableForDistributedTests.swift %S/../Inputs/FakeDistributedActorSystems.swift
5+ // RUN: %target-build-swift -module-name main -Xfrontend -enable-experimental-distributed -Xfrontend -disable-availability-checking -j2 -parse-as-library -I %t %s %S/../Inputs/FakeCodableForDistributedTests.swift %S/../Inputs/FakeDistributedActorSystems.swift -o %t/a.out
6+ // RUN: %target-codesign %t/a.out
7+ // RUN: %target-run %t/a.out | %FileCheck %s
8+
9+ // REQUIRES: executable_test
10+ // REQUIRES: concurrency
11+ // REQUIRES: distributed
12+
13+ // rdar://76038845
14+ // UNSUPPORTED: use_os_stdlib
15+ // UNSUPPORTED: back_deployment_runtime
16+
17+ import Distributed
18+ import FakeDistributedActorSystems
19+ import FakeCodableForDistributedTests
20+
21+ typealias DefaultDistributedActorSystem = FakeRoundtripActorSystem
22+
23+ class Sentinel {
24+ let str : String
25+
26+ init ( _ str: String ) {
27+ self . str = str
28+ print ( " \( str) .init: \( Unmanaged . passUnretained ( self ) . toOpaque ( ) ) " )
29+ }
30+
31+ deinit {
32+ print ( " \( str) .deinit: \( Unmanaged . passUnretained ( self ) . toOpaque ( ) ) " )
33+ }
34+ }
35+
36+ struct InnerStruct1 {
37+ let sentinel : Sentinel
38+ let innerStruct2 : InnerStruct2
39+
40+ init ( ) {
41+ self . sentinel = Sentinel ( " \( Self . self) " )
42+ self . innerStruct2 = InnerStruct2 ( )
43+ }
44+ }
45+
46+ struct InnerStruct2 {
47+ let sentinel : Sentinel
48+
49+ init ( ) {
50+ self . sentinel = Sentinel ( " \( Self . self) " )
51+ }
52+ }
53+
54+ enum InnerEnum {
55+ case v1( String )
56+ case v2( InnerStruct1 )
57+ }
58+
59+ struct ArgumentType : Codable {
60+ let sentinel : Sentinel
61+ let value : Int
62+ let innerEnum : InnerEnum
63+
64+ init ( _ value: Int ) {
65+ self . sentinel = Sentinel ( " ArgumentType " )
66+ self . value = value
67+ self . innerEnum = . v2( InnerStruct1 ( ) )
68+ }
69+
70+ init ( from decoder: Decoder ) throws {
71+ self . sentinel = Sentinel ( " ArgumentType " )
72+ self . value = 100
73+ self . innerEnum = . v2( InnerStruct1 ( ) )
74+ }
75+
76+ func encode( to encoder: Encoder ) throws {
77+ print ( " ArgumentType.encode " )
78+ }
79+ }
80+
81+ distributed actor TestActor {
82+ public distributed func testFunc( arg: ArgumentType ) {
83+ print ( " value= \( arg. value) " )
84+ }
85+ }
86+
87+ @main
88+ struct Main {
89+
90+ static func main( ) async throws {
91+ let system = DefaultDistributedActorSystem ( )
92+
93+ let instance = TestActor ( actorSystem: system)
94+ let resolved = try TestActor . resolve ( id: instance. id, using: system)
95+
96+ // CHECK: ArgumentType.init: [[P1:0x[0-9]+]]
97+ // CHECK: InnerStruct1.init: [[P2:0x[0-9]+]]
98+ // CHECK: InnerStruct2.init: [[P3:0x[0-9]+]]
99+
100+ // CHECK: ArgumentType.deinit: [[P1]]
101+ // CHECK: InnerStruct1.deinit: [[P2]]
102+ // CHECK: InnerStruct2.deinit: [[P3]]
103+
104+ let arg = ArgumentType ( 100 )
105+ try await resolved. testFunc ( arg: arg)
106+ }
107+ }
0 commit comments