Skip to content

Commit 9a76323

Browse files
committed
throwing sync inits are also not fully working
1 parent f75a6e9 commit 9a76323

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

test/Distributed/Runtime/distributed_actor_init_local.swift

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
import _Distributed
1212

13+
enum MyError: Error {
14+
case test
15+
}
16+
1317
@available(SwiftStdlib 5.5, *)
1418
distributed actor PickATransport1 {
1519
init(kappa transport: ActorTransport, other: Int) {}
@@ -36,6 +40,26 @@ distributed actor Bug_CallsReadyTwice {
3640
}
3741
}
3842

43+
@available(SwiftStdlib 5.5, *)
44+
distributed actor Throwy {
45+
init(transport: ActorTransport, doThrow: Bool) throws {
46+
if doThrow {
47+
throw MyError.test
48+
}
49+
}
50+
}
51+
52+
@available(SwiftStdlib 5.5, *)
53+
distributed actor ThrowBeforeFullyInit {
54+
var x: Int
55+
init(transport: ActorTransport, doThrow: Bool) throws {
56+
if doThrow {
57+
throw MyError.test
58+
}
59+
self.x = 0
60+
}
61+
}
62+
3963
// ==== Fake Transport ---------------------------------------------------------
4064

4165
@available(SwiftStdlib 5.5, *)
@@ -89,10 +113,27 @@ func test() async {
89113
// CHECK: ready actor:main.PickATransport1, id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
90114
// CHECK: resign id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
91115

116+
_ = try? Throwy(transport: transport, doThrow: false)
117+
// CHECK: assign type:Throwy, id:ActorAddress(address: "[[ID:.*]]")
118+
// CHECK: ready actor:main.Throwy, id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
119+
// CHECK: resign id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
120+
121+
_ = try? Throwy(transport: transport, doThrow: true)
122+
// CHECK: assign type:Throwy, id:ActorAddress(address: "[[ID:.*]]")
123+
// CHECK-NOT: ready
124+
// CHECK: resign id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
125+
126+
_ = try? ThrowBeforeFullyInit(transport: transport, doThrow: true)
127+
// CHECK: assign type:ThrowBeforeFullyInit, id:ActorAddress(address: "[[ID:.*]]")
128+
// FIXME: The two checks below should work, but do not currently, so they're disabled (rdar://84533820).
129+
// MISSING-CHECK-NOT: ready actor:main.ThrowBeforeFullyInit
130+
// MISSING-CHECK: resign id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
131+
92132
_ = await PickATransport2(other: 1, theTransport: transport)
93133
// CHECK: assign type:PickATransport2, id:ActorAddress(address: "[[ID:.*]]")
94134
// CHECK: ready actor:main.PickATransport2, id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
95135

136+
// FIXME: The checks for this initializer should NOT pass, but currently do. (rdar://84533820)
96137
_ = await Bug_CallsReadyTwice(transport: transport, wantBug: true)
97138
// CHECK: assign type:Bug_CallsReadyTwice, id:ActorAddress(address: "[[ID:.*]]")
98139
// CHECK: ready actor:main.Bug_CallsReadyTwice, id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))

0 commit comments

Comments
 (0)