Skip to content

🍒[5.7][Distributed] Diagnose missing inout on remoteCall decls #58683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/AST/DistributedDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,12 +491,14 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn)
return false;
}

// --- Check parameter: invocation InvocationEncoder
// FIXME: NOT INOUT, but we crash today if not
// --- Check parameter: invocation: inout InvocationEncoder
auto invocationParam = params->get(2);
if (invocationParam->getArgumentName() != C.Id_invocation) {
return false;
}
if (!invocationParam->isInOut()) {
return false;
}

// --- Check parameter: throwing: Err.Type
auto thrownTypeParam = params->get(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,67 @@ struct MissingRemoteCall: DistributedActorSystem {
}
}

struct MissingRemoteCall_missingInout_on_encoder: DistributedActorSystem {
// expected-error@-1{{struct 'MissingRemoteCall_missingInout_on_encoder' is missing witness for protocol requirement 'remoteCall'}}
// expected-note@-2{{protocol 'MissingRemoteCall_missingInout_on_encoder' requires function 'remoteCall' with signature:}}

// expected-error@-4{{struct 'MissingRemoteCall_missingInout_on_encoder' is missing witness for protocol requirement 'remoteCallVoid'}}
// expected-note@-5{{protocol 'MissingRemoteCall_missingInout_on_encoder' requires function 'remoteCallVoid' with signature:}}

typealias ActorID = ActorAddress
typealias InvocationDecoder = FakeInvocationDecoder
typealias InvocationEncoder = FakeInvocationEncoder
typealias SerializationRequirement = Codable
typealias ResultHandler = FakeResultHandler

func resolve<Act>(id: ActorID, as actorType: Act.Type)
throws -> Act? where Act: DistributedActor {
return nil
}

func assignID<Act>(_ actorType: Act.Type) -> ActorID
where Act: DistributedActor {
ActorAddress(parse: "fake://123")
}

func actorReady<Act>(_ actor: Act)
where Act: DistributedActor,
Act.ID == ActorID {
}

func resignID(_ id: ActorID) {
}

func remoteCall<Act, Err, Res>(
on actor: Act,
target: RemoteCallTarget,
invocation: InvocationEncoder, // MISSING 'inout'
throwing: Err.Type,
returning: Res.Type
) async throws -> Res
where Act: DistributedActor,
Act.ID == ActorID,
Err: Error,
Res: SerializationRequirement {
fatalError("NOT IMPLEMENTED \(#function)")
}

func remoteCallVoid<Act, Err>(
on actor: Act,
target: RemoteCallTarget,
invocation: InvocationEncoder, // MISSING 'inout'
throwing: Err.Type
) async throws
where Act: DistributedActor,
Act.ID == ActorID,
Err: Error {
fatalError("NOT IMPLEMENTED \(#function)")
}

func makeInvocationEncoder() -> InvocationEncoder {
}
}

struct MissingRemoteCall_missing_makeInvocationEncoder: DistributedActorSystem {
// expected-error@-1{{type 'MissingRemoteCall_missing_makeInvocationEncoder' does not conform to protocol 'DistributedActorSystem'}}

Expand Down