4
4
5
5
import _Distributed
6
6
7
- @available ( SwiftStdlib 5 . 5 , * )
8
7
distributed actor OK0 { }
9
8
10
- @available ( SwiftStdlib 5 . 5 , * )
11
9
distributed actor OK1 {
12
10
var x : Int = 1
13
11
// ok, since all fields are initialized, the constructor can be synthesized
14
12
}
15
13
16
14
// TODO(distributed): test all the FIXITs in this file
17
15
18
- @available ( SwiftStdlib 5 . 5 , * )
19
16
distributed actor Bad1 {
20
17
init ( ) {
21
18
// expected-error@-1 {{designated distributed actor initializer 'init()' is missing required ActorTransport parameter}}
22
19
}
23
20
}
24
21
25
- @available ( SwiftStdlib 5 . 5 , * )
26
22
distributed actor Bad12 {
27
23
init ( x: String ) {
28
24
// expected-error@-1 {{designated distributed actor initializer 'init(x:)' is missing required ActorTransport parameter}}
29
25
}
30
26
}
31
27
32
- @available ( SwiftStdlib 5 . 5 , * )
33
28
distributed actor OK2 {
34
29
var x : Int
35
30
@@ -38,7 +33,6 @@ distributed actor OK2 {
38
33
}
39
34
}
40
35
41
- @available ( SwiftStdlib 5 . 5 , * )
42
36
distributed actor Bad2 {
43
37
var x : Int = 1
44
38
@@ -47,7 +41,6 @@ distributed actor Bad2 {
47
41
}
48
42
}
49
43
50
- @available ( SwiftStdlib 5 . 5 , * )
51
44
distributed actor OK3 {
52
45
var x : Int
53
46
@@ -56,11 +49,60 @@ distributed actor OK3 {
56
49
}
57
50
}
58
51
59
- @available ( SwiftStdlib 5 . 5 , * )
60
52
distributed actor OKMulti {
61
53
62
54
convenience init ( y: Int , transport: ActorTransport ) { // ok
63
55
self . init ( transport: transport)
64
56
}
65
57
66
58
}
59
+
60
+ distributed actor OKMultiDefaultValues {
61
+
62
+ convenience init ( y: Int , transport: ActorTransport , x: Int = 1234 ) { // ok
63
+ self . init ( transport: transport)
64
+ }
65
+
66
+ }
67
+
68
+ // ==== ------------------------------------------------------------------------
69
+ // MARK: Specific transport
70
+
71
+ struct ActorAddress : ActorIdentity {
72
+ let address : String
73
+ init ( parse address : String ) {
74
+ self . address = address
75
+ }
76
+ }
77
+
78
+ struct FakeTransport : ActorTransport {
79
+ func decodeIdentity( from decoder: Decoder ) throws -> AnyActorIdentity {
80
+ fatalError ( " not implemented \( #function) " )
81
+ }
82
+
83
+ func resolve< Act> ( _ identity: AnyActorIdentity , as actorType: Act . Type ) throws -> Act ?
84
+ where Act: DistributedActor {
85
+ return nil
86
+ }
87
+
88
+ func assignIdentity< Act> ( _ actorType: Act . Type ) -> AnyActorIdentity
89
+ where Act: DistributedActor {
90
+ . init( ActorAddress ( parse: " " ) )
91
+ }
92
+
93
+ public func actorReady< Act> ( _ actor : Act )
94
+ where Act: DistributedActor {
95
+ print ( " \( #function) : \( actor ) " )
96
+ }
97
+
98
+ func resignIdentity( _ id: AnyActorIdentity ) { }
99
+ }
100
+
101
+ distributed actor OKSpecificTransportType {
102
+
103
+ init ( y: Int , transport fake: FakeTransport ) { // ok
104
+ defer { fake. actorReady ( self ) }
105
+ // nothing
106
+ }
107
+
108
+ }
0 commit comments