Skip to content

Commit c6d1395

Browse files
committed
[Sema/IRGen] Extend ad-hoc requirement handling to DistributedTargetInvocationResultHandler.onReturn
1 parent e500ab3 commit c6d1395

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

lib/IRGen/GenProto.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ class EmitPolymorphicParameters : public PolymorphicConvention {
552552
// `DistributedActorSystem.remoteCall` or
553553
// `DistributedTargetInvocationEncoder.record{Argument, ReturnType}`
554554
// `DistributedTargetInvocationDecoder.decodeNextArgument`
555+
// `DistributedTargetInvocationResultHandler.onReturn`
555556
// requirements we need to supply witness tables associated with `Res`,
556557
// `Argument`, `R` generic parameters which are not expressible on the
557558
// protocol requirement because they come from `SerializationRequirement`
@@ -752,19 +753,21 @@ void EmitPolymorphicParameters::injectAdHocDistributedRequirements() {
752753
genericParam = funcDecl->getResultInterfaceType();
753754
}
754755

756+
auto sig = funcDecl->getGenericSignature();
757+
755758
// DistributedTargetInvocationEncoder.record{Argument, ReturnType}
756759
// DistributedTargetInvocationDecoder.decodeNextArgument
760+
// DistributedTargetInvocationResultHandler.onReturn
757761
if (funcDecl->isDistributedTargetInvocationEncoderRecordArgument() ||
758762
funcDecl->isDistributedTargetInvocationEncoderRecordReturnType() ||
759-
funcDecl->isDistributedTargetInvocationDecoderDecodeNextArgument()) {
760-
auto *argParam = funcDecl->getGenericParams()->getParams().front();
761-
genericParam = argParam->getDeclaredInterfaceType();
763+
funcDecl->isDistributedTargetInvocationDecoderDecodeNextArgument() ||
764+
funcDecl->isDistributedTargetInvocationResultHandlerOnReturn()) {
765+
genericParam = sig.getInnermostGenericParams().front();
762766
}
763767

764768
if (!genericParam)
765769
return;
766770

767-
auto sig = funcDecl->getGenericSignature();
768771
auto requirements = sig->getLocalRequirements(genericParam);
769772
if (requirements.protos.empty())
770773
return;

lib/Sema/CSSimplify.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8505,9 +8505,12 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
85058505

85068506
// `DistributedTargetInvocationEncoder.record{Argument, ResultType}`
85078507
// `DistributedTargetInvocationDecoder.decodeNextArgument`
8508+
// `DistributedTargetInvocationResultHandler.onReturn`
85088509
if (witness->isDistributedTargetInvocationEncoderRecordArgument() ||
85098510
witness->isDistributedTargetInvocationEncoderRecordReturnType() ||
8510-
witness->isDistributedTargetInvocationDecoderDecodeNextArgument()) {
8511+
witness
8512+
->isDistributedTargetInvocationDecoderDecodeNextArgument() ||
8513+
witness->isDistributedTargetInvocationResultHandlerOnReturn()) {
85118514
auto genericParams = witness->getGenericParams()->getParams();
85128515
if (GP->isEqual(genericParams.front()->getDeclaredInterfaceType()))
85138516
return synthesizeConformance();

stdlib/public/Distributed/DistributedActorSystem.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -947,11 +947,9 @@ public protocol DistributedTargetInvocationResultHandler {
947947
/// The serialization requirement that the value passed to `onReturn` is required to conform to.
948948
associatedtype SerializationRequirement
949949

950-
// /// Ad-hoc protocol requirement
951-
// ///
952-
// /// Invoked when the distributed target execution returns successfully.
953-
// /// The `value` is the return value of the executed distributed invocation target.
954-
// func onReturn<Success: SerializationRequirement>(value: Success) async throws
950+
/// Invoked when the distributed target execution returns successfully.
951+
/// The `value` is the return value of the executed distributed invocation target.
952+
func onReturn<Success/*: SerializationRequirement*/>(value: Success) async throws
955953

956954
/// Invoked when the distributed target execution of a `Void` returning
957955
/// function has completed successfully.

0 commit comments

Comments
 (0)