24
24
#include " swift/AST/ExistentialLayout.h"
25
25
#include " swift/AST/NameLookupRequests.h"
26
26
#include " swift/AST/ParameterList.h"
27
+ #include " swift/AST/ProtocolConformance.h"
27
28
#include " swift/Basic/Assertions.h"
28
29
#include " swift/Strings.h"
29
30
@@ -552,14 +553,29 @@ deriveDistributedActorType_ActorSystem(
552
553
return defaultDistributedActorSystemTypeDecl->getDeclaredInterfaceType ();
553
554
}
554
555
556
+ static Type getDistributedActorSystem (DerivedConformance &derived) {
557
+ auto *assocType = derived.Protocol ->getAssociatedType (
558
+ derived.Context .Id_ActorSystem );
559
+ if (!assocType)
560
+ return Type ();
561
+
562
+ // This is called from inside associated type inference itself, so if we
563
+ // haven't populate the type witness yet, it won't be found by name
564
+ // lookup, and calling getTypeWitness() will trigger a request cycle.
565
+ if (!derived.Conformance ->hasTypeWitness (assocType))
566
+ return Type ();
567
+
568
+ return derived.Conformance ->getTypeWitness (assocType);
569
+ }
570
+
555
571
static Type
556
572
deriveDistributedActorType_ID (
557
573
DerivedConformance &derived) {
558
574
if (!derived.Nominal ->isDistributedActor ())
559
575
return nullptr ;
560
576
561
577
// Look for a type DefaultDistributedActorSystem within the parent context.
562
- auto systemTy = getDistributedActorSystemType (derived. Nominal );
578
+ auto systemTy = getDistributedActorSystem (derived);
563
579
564
580
// There is no known actor system type, so fail to synthesize.
565
581
if (!systemTy || systemTy->hasError ())
@@ -579,7 +595,7 @@ deriveDistributedActorType_SerializationRequirement(
579
595
return nullptr ;
580
596
581
597
// Look for a type DefaultDistributedActorSystem within the parent context.
582
- auto systemTy = getDistributedActorSystemType (derived. Nominal );
598
+ auto systemTy = getDistributedActorSystem (derived);
583
599
584
600
// There is no known actor system type, so fail to synthesize.
585
601
if (!systemTy || systemTy->hasError ())
0 commit comments