@@ -166,65 +166,46 @@ Type swift::getDistributedActorIDType(NominalTypeDecl *actor) {
166166 return getAssociatedTypeOfDistributedSystemOfActor (actor, C.Id_ActorID );
167167}
168168
169- Type swift::getDistributedActorSystemActorIDType (NominalTypeDecl *system) {
170- assert (!system->isDistributedActor ());
171- auto &ctx = system->getASTContext ();
169+ static Type getTypeWitnessByName (NominalTypeDecl *type, ProtocolDecl *protocol,
170+ Identifier member) {
171+ if (!protocol)
172+ return ErrorType::get (type->getASTContext ());
172173
173- auto DAS = ctx.getDistributedActorSystemDecl ();
174- if (!DAS)
174+ auto module = type->getParentModule ();
175+ Type selfType = type->getSelfInterfaceType ();
176+ auto conformance = module ->lookupConformance (selfType, protocol);
177+ if (!conformance || conformance.isInvalid ())
175178 return Type ();
179+ return conformance.getTypeWitnessByName (selfType, member);
180+ }
176181
177- // Dig out the serialization requirement type.
178- auto module = system->getParentModule ( );
179- Type selfType = system->getSelfInterfaceType ();
180- auto conformance = module -> lookupConformance (selfType, DAS);
181- return conformance. getTypeWitnessByName (selfType, ctx.Id_ActorID );
182+ Type swift::getDistributedActorSystemActorIDType (NominalTypeDecl *system) {
183+ assert (! system->isDistributedActor () );
184+ auto &ctx = system->getASTContext ();
185+ return getTypeWitnessByName (system, ctx. getDistributedActorSystemDecl (),
186+ ctx.Id_ActorID );
182187}
183188
184189Type swift::getDistributedActorSystemResultHandlerType (
185190 NominalTypeDecl *system) {
186191 assert (!system->isDistributedActor ());
187192 auto &ctx = system->getASTContext ();
188-
189- auto DAS = ctx.getDistributedActorSystemDecl ();
190- if (!DAS)
191- return Type ();
192-
193- // Dig out the serialization requirement type.
194- auto module = system->getParentModule ();
195- Type selfType = system->getSelfInterfaceType ();
196- auto conformance = module ->lookupConformance (selfType, DAS);
197- return conformance.getTypeWitnessByName (selfType, ctx.Id_ResultHandler );
193+ return getTypeWitnessByName (system, ctx.getDistributedActorSystemDecl (),
194+ ctx.Id_ResultHandler );
198195}
199196
200197Type swift::getDistributedActorSystemInvocationEncoderType (NominalTypeDecl *system) {
201198 assert (!system->isDistributedActor ());
202199 auto &ctx = system->getASTContext ();
203-
204- auto DAS = ctx.getDistributedActorSystemDecl ();
205- if (!DAS)
206- return Type ();
207-
208- // Dig out the serialization requirement type.
209- auto module = system->getParentModule ();
210- Type selfType = system->getSelfInterfaceType ();
211- auto conformance = module ->lookupConformance (selfType, DAS);
212- return conformance.getTypeWitnessByName (selfType, ctx.Id_InvocationEncoder );
200+ return getTypeWitnessByName (system, ctx.getDistributedActorSystemDecl (),
201+ ctx.Id_InvocationEncoder );
213202}
214203
215204Type swift::getDistributedActorSystemInvocationDecoderType (NominalTypeDecl *system) {
216205 assert (!system->isDistributedActor ());
217206 auto &ctx = system->getASTContext ();
218-
219- auto DAS = ctx.getDistributedActorSystemDecl ();
220- if (!DAS)
221- return Type ();
222-
223- // Dig out the serialization requirement type.
224- auto module = system->getParentModule ();
225- Type selfType = system->getSelfInterfaceType ();
226- auto conformance = module ->lookupConformance (selfType, DAS);
227- return conformance.getTypeWitnessByName (selfType, ctx.Id_InvocationDecoder );
207+ return getTypeWitnessByName (system, ctx.getDistributedActorSystemDecl (),
208+ ctx.Id_InvocationDecoder );
228209}
229210
230211Type swift::getDistributedSerializationRequirementType (
0 commit comments