Skip to content

Commit ff211b7

Browse files
authored
Merge pull request #58672 from ktoso/wip-missing-inout-diagnose
[Distributed] Diagnose missing inout on remoteCall decls
2 parents 4a8f9a5 + 90e034f commit ff211b7

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
@@ -464,12 +464,14 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn)
464464
return false;
465465
}
466466

467-
// --- Check parameter: invocation InvocationEncoder
468-
// FIXME: NOT INOUT, but we crash today if not
467+
// --- Check parameter: invocation: inout InvocationEncoder
469468
auto invocationParam = params->get(2);
470469
if (invocationParam->getArgumentName() != C.Id_invocation) {
471470
return false;
472471
}
472+
if (!invocationParam->isInOut()) {
473+
return false;
474+
}
473475

474476
// --- Check parameter: throwing: Err.Type
475477
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)