@@ -275,7 +275,12 @@ Type ASTContext::getAssociatedTypeOfDistributedSystemOfActor(
275
275
276
276
auto actorProtocol = ctx.getProtocol (KnownProtocolKind::DistributedActor);
277
277
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 ();
279
284
280
285
AssociatedTypeDecl *actorSystemDecl =
281
286
actorProtocol->getAssociatedType (ctx.Id_ActorSystem );
@@ -286,37 +291,20 @@ Type ASTContext::getAssociatedTypeOfDistributedSystemOfActor(
286
291
if (!actorSystemProtocol)
287
292
return Type ();
288
293
289
- AssociatedTypeDecl *assocTypeDecl =
294
+ AssociatedTypeDecl *memberTypeDecl =
290
295
actorSystemProtocol->getAssociatedType (member);
291
- if (!assocTypeDecl )
296
+ if (!memberTypeDecl )
292
297
return Type ();
293
298
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);
299
303
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);
317
306
318
- return dependentType.subst (SubstitutionMap::getProtocolSubstitutions (
319
- actorProtocol, selfType, conformance));
307
+ return Type (depMemTy).subst (subs);
320
308
}
321
309
322
310
/* *****************************************************************************/
0 commit comments