@@ -581,6 +581,11 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordArgument() const
581581 auto &C = getASTContext ();
582582 auto module = getParentModule ();
583583
584+ auto func = dyn_cast<FuncDecl>(this );
585+ if (!func) {
586+ return false ;
587+ }
588+
584589 // === Check base name
585590 if (getBaseIdentifier () != C.Id_recordArgument ) {
586591 return false ;
@@ -614,6 +619,12 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordArgument() const
614619 return false ;
615620 }
616621
622+ // --- must be mutating, if it is defined in a struct
623+ if (isa<StructDecl>(getDeclContext ()) &&
624+ !func->isMutating ()) {
625+ return false ;
626+ }
627+
617628 // --- Check number of generic parameters
618629 auto genericParams = getGenericParams ();
619630 unsigned int expectedGenericParamNum = 1 ;
@@ -635,28 +646,43 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordArgument() const
635646
636647 // === Check all parameters
637648 auto params = getParameters ();
638- if (params->size () != 2 ) {
649+ if (params->size () != 1 ) {
639650 return false ;
640651 }
641652
642- // --- Check parameter: label
643- auto labelParam = params->get (0 );
644- if (!labelParam->getArgumentName ().is (" name" )) {
645- return false ;
646- }
647- if (!labelParam->getInterfaceType ()->isEqual (C.getStringType ())) {
653+ GenericTypeParamDecl *ArgumentParam = genericParams->getParams ()[0 ];
654+
655+ // --- Check parameter: _ argument
656+ auto argumentParam = params->get (0 );
657+ if (!argumentParam->getArgumentName ().empty ()) {
648658 return false ;
649659 }
650660
651- // --- Check parameter: _ argument
652- auto argumentParam = params->get (1 );
653- if (!argumentParam->getArgumentName ().is (" " )) {
661+ auto argumentTy = argumentParam->getInterfaceType ();
662+ auto argumentInContextTy = mapTypeIntoContext (argumentTy);
663+ if (argumentInContextTy->getAnyNominal () == C.getRemoteCallArgumentDecl ()) {
664+ auto argGenericParams = argumentInContextTy->getStructOrBoundGenericStruct ()
665+ ->getGenericParams ()->getParams ();
666+ if (argGenericParams.size () != 1 ) {
667+ return false ;
668+ }
669+
670+ // the <Value> of the RemoteCallArgument<Value>
671+ auto remoteCallArgValueGenericTy =
672+ mapTypeIntoContext (argGenericParams[0 ]->getInterfaceType ())
673+ ->getDesugaredType ()
674+ ->getMetatypeInstanceType ();
675+ // expected (the <Value> from the recordArgument<Value>)
676+ auto expectedGenericParamTy = mapTypeIntoContext (
677+ ArgumentParam->getInterfaceType ()->getMetatypeInstanceType ());
678+
679+ if (!remoteCallArgValueGenericTy->isEqual (expectedGenericParamTy)) {
680+ return false ;
681+ }
682+ } else {
654683 return false ;
655684 }
656685
657- // === Check generic parameters in detail
658- // --- Check: Argument: SerializationRequirement
659- GenericTypeParamDecl *ArgumentParam = genericParams->getParams ()[0 ];
660686
661687 auto sig = getGenericSignature ();
662688 auto requirements = sig.getRequirements ();
@@ -672,29 +698,6 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordArgument() const
672698 // conforms_to: Argument Encodable
673699 // ...
674700
675- auto func = dyn_cast<FuncDecl>(this );
676- if (!func) {
677- return false ;
678- }
679-
680- auto resultType =
681- func->mapTypeIntoContext (argumentParam->getInterfaceType ())
682- ->getDesugaredType ();
683- auto resultParamType = func->mapTypeIntoContext (
684- ArgumentParam->getInterfaceType ()->getMetatypeInstanceType ());
685- // The result of the function must be the `Res` generic argument.
686- if (!resultType->isEqual (resultParamType)) {
687- return false ;
688- }
689-
690- for (auto requirementProto : requirementProtos) {
691- auto conformance =
692- module ->lookupConformance (resultType, requirementProto);
693- if (conformance.isInvalid ()) {
694- return false ;
695- }
696- }
697-
698701 // === Check result type: Void
699702 if (!func->getResultInterfaceType ()->isVoid ()) {
700703 return false ;
@@ -1152,6 +1155,14 @@ NominalTypeDecl::getDistributedRemoteCallTargetInitFunction() const {
11521155 GetDistributedRemoteCallTargetInitFunctionRequest (mutableThis), nullptr );
11531156}
11541157
1158+ ConstructorDecl *
1159+ NominalTypeDecl::getDistributedRemoteCallArgumentInitFunction () const {
1160+ auto mutableThis = const_cast <NominalTypeDecl *>(this );
1161+ return evaluateOrDefault (
1162+ getASTContext ().evaluator ,
1163+ GetDistributedRemoteCallArgumentInitFunctionRequest (mutableThis), nullptr );
1164+ }
1165+
11551166AbstractFunctionDecl *ASTContext::getRemoteCallOnDistributedActorSystem (
11561167 NominalTypeDecl *actorOrSystem, bool isVoidReturn) const {
11571168 assert (actorOrSystem && " distributed actor (or system) decl must be provided" );
0 commit comments