@@ -275,7 +275,12 @@ Type ASTContext::getAssociatedTypeOfDistributedSystemOfActor(
275275
276276 auto actorProtocol = ctx.getProtocol (KnownProtocolKind::DistributedActor);
277277 if (!actorProtocol)
278- return ErrorType::get (ctx);
278+ return Type ();
279+
280+ auto actorConformance = actor->getParentModule ()->lookupConformance (
281+ actor->getDeclaredInterfaceType (), actorProtocol);
282+ if (!actorConformance || actorConformance.isInvalid ())
283+ return Type ();
279284
280285 AssociatedTypeDecl *actorSystemDecl =
281286 actorProtocol->getAssociatedType (ctx.Id_ActorSystem );
@@ -286,37 +291,20 @@ Type ASTContext::getAssociatedTypeOfDistributedSystemOfActor(
286291 if (!actorSystemProtocol)
287292 return Type ();
288293
289- AssociatedTypeDecl *assocTypeDecl =
294+ AssociatedTypeDecl *memberTypeDecl =
290295 actorSystemProtocol->getAssociatedType (member);
291- if (!assocTypeDecl )
296+ if (!memberTypeDecl )
292297 return Type ();
293298
294- auto module = actor->getParentModule ();
295-
296- // In case of protocol, let's find a concrete `ActorSystem`
297- if (auto *protocol = dyn_cast<ProtocolDecl>(actor)) {
298- auto signature = protocol->getGenericSignatureOfContext ();
299+ auto depMemTy = DependentMemberType::get (
300+ DependentMemberType::get (actorProtocol->getSelfInterfaceType (),
301+ actorSystemDecl),
302+ memberTypeDecl);
299303
300- auto systemTy =
301- signature->getConcreteType (actorSystemDecl->getDeclaredInterfaceType ());
302- if (!systemTy)
303- return Type ();
304-
305- auto conformance = module ->lookupConformance (systemTy, actorSystemProtocol);
306- if (conformance.isInvalid ())
307- return Type ();
308-
309- return conformance.getTypeWitnessByName (systemTy, member);
310- }
311-
312- Type selfType = actor->getSelfInterfaceType ();
313- auto conformance = module ->lookupConformance (selfType, actorProtocol);
314- Type dependentType = actorProtocol->getSelfInterfaceType ();
315- dependentType = DependentMemberType::get (dependentType, actorSystemDecl);
316- dependentType = DependentMemberType::get (dependentType, assocTypeDecl);
304+ auto subs = SubstitutionMap::getProtocolSubstitutions (
305+ actorProtocol, actor->getDeclaredInterfaceType (), actorConformance);
317306
318- return dependentType.subst (SubstitutionMap::getProtocolSubstitutions (
319- actorProtocol, selfType, conformance));
307+ return Type (depMemTy).subst (subs);
320308}
321309
322310/* *****************************************************************************/
0 commit comments