Skip to content

Commit 59a3dda

Browse files
committed
[Distributed] Diagnose missing inout on remoteCall decls
1 parent fc30104 commit 59a3dda

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

lib/AST/DistributedDecl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,12 +491,14 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn)
491491
return false;
492492
}
493493

494-
// --- Check parameter: invocation InvocationEncoder
495-
// FIXME: NOT INOUT, but we crash today if not
494+
// --- Check parameter: invocation: inout InvocationEncoder
496495
auto invocationParam = params->get(2);
497496
if (invocationParam->getArgumentName() != C.Id_invocation) {
498497
return false;
499498
}
499+
if (!invocationParam->isInOut()) {
500+
return false;
501+
}
500502

501503
// --- Check parameter: throwing: Err.Type
502504
auto thrownTypeParam = params->get(3);

test/Distributed/distributed_actor_system_missing_adhoc_requirement_impls.swift

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,67 @@ struct MissingRemoteCall: DistributedActorSystem {
4141
}
4242
}
4343

44+
struct MissingRemoteCall_missingInout_on_encoder: DistributedActorSystem {
45+
// expected-error@-1{{struct 'MissingRemoteCall_missingInout_on_encoder' is missing witness for protocol requirement 'remoteCall'}}
46+
// expected-note@-2{{protocol 'MissingRemoteCall_missingInout_on_encoder' requires function 'remoteCall' with signature:}}
47+
48+
// expected-error@-4{{struct 'MissingRemoteCall_missingInout_on_encoder' is missing witness for protocol requirement 'remoteCallVoid'}}
49+
// expected-note@-5{{protocol 'MissingRemoteCall_missingInout_on_encoder' requires function 'remoteCallVoid' with signature:}}
50+
51+
typealias ActorID = ActorAddress
52+
typealias InvocationDecoder = FakeInvocationDecoder
53+
typealias InvocationEncoder = FakeInvocationEncoder
54+
typealias SerializationRequirement = Codable
55+
typealias ResultHandler = FakeResultHandler
56+
57+
func resolve<Act>(id: ActorID, as actorType: Act.Type)
58+
throws -> Act? where Act: DistributedActor {
59+
return nil
60+
}
61+
62+
func assignID<Act>(_ actorType: Act.Type) -> ActorID
63+
where Act: DistributedActor {
64+
ActorAddress(parse: "fake://123")
65+
}
66+
67+
func actorReady<Act>(_ actor: Act)
68+
where Act: DistributedActor,
69+
Act.ID == ActorID {
70+
}
71+
72+
func resignID(_ id: ActorID) {
73+
}
74+
75+
func remoteCall<Act, Err, Res>(
76+
on actor: Act,
77+
target: RemoteCallTarget,
78+
invocation: InvocationEncoder, // MISSING 'inout'
79+
throwing: Err.Type,
80+
returning: Res.Type
81+
) async throws -> Res
82+
where Act: DistributedActor,
83+
Act.ID == ActorID,
84+
Err: Error,
85+
Res: SerializationRequirement {
86+
fatalError("NOT IMPLEMENTED \(#function)")
87+
}
88+
89+
func remoteCallVoid<Act, Err>(
90+
on actor: Act,
91+
target: RemoteCallTarget,
92+
invocation: InvocationEncoder, // MISSING 'inout'
93+
throwing: Err.Type
94+
) async throws
95+
where Act: DistributedActor,
96+
Act.ID == ActorID,
97+
Err: Error {
98+
fatalError("NOT IMPLEMENTED \(#function)")
99+
}
100+
101+
func makeInvocationEncoder() -> InvocationEncoder {
102+
}
103+
}
104+
44105
struct MissingRemoteCall_missing_makeInvocationEncoder: DistributedActorSystem {
45106
// expected-error@-1{{type 'MissingRemoteCall_missing_makeInvocationEncoder' does not conform to protocol 'DistributedActorSystem'}}
46107

0 commit comments

Comments
 (0)