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,27 @@ 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
+
560
+ // This is called from inside associated type inference itself, so if we
561
+ // haven't populate the type witness yet, it won't be found by name
562
+ // lookup, and calling getTypeWitness() will trigger a request cycle.
563
+ if (!derived.Conformance ->hasTypeWitness (assocType))
564
+ return Type ();
565
+
566
+ return derived.Conformance ->getTypeWitness (assocType);
567
+ }
568
+
555
569
static Type
556
570
deriveDistributedActorType_ID (
557
571
DerivedConformance &derived) {
558
572
if (!derived.Nominal ->isDistributedActor ())
559
573
return nullptr ;
560
574
561
575
// Look for a type DefaultDistributedActorSystem within the parent context.
562
- auto systemTy = getDistributedActorSystemType (derived. Nominal );
576
+ auto systemTy = getDistributedActorSystem (derived);
563
577
564
578
// There is no known actor system type, so fail to synthesize.
565
579
if (!systemTy || systemTy->hasError ())
@@ -579,7 +593,7 @@ deriveDistributedActorType_SerializationRequirement(
579
593
return nullptr ;
580
594
581
595
// Look for a type DefaultDistributedActorSystem within the parent context.
582
- auto systemTy = getDistributedActorSystemType (derived. Nominal );
596
+ auto systemTy = getDistributedActorSystem (derived);
583
597
584
598
// There is no known actor system type, so fail to synthesize.
585
599
if (!systemTy || systemTy->hasError ())
0 commit comments