@@ -5475,6 +5475,32 @@ void swift::diagnoseConformanceFailure(Type T,
5475
5475
return ;
5476
5476
}
5477
5477
5478
+ // Special case: a distributed actor conformance often can fail because of
5479
+ // a missing ActorSystem (or DefaultDistributedActorSystem) typealias.
5480
+ // In this case, the "normal" errors are an avalanche of errors related to
5481
+ // missing things in the actor that don't help users diagnose the root problem.
5482
+ // Instead, we want to suggest adding the typealias.
5483
+ if (Proto->isSpecificProtocol (KnownProtocolKind::DistributedActor)) {
5484
+ auto nominal = T->getNominalOrBoundGenericNominal ();
5485
+ if (!nominal)
5486
+ return ;
5487
+
5488
+ // If it is missing the ActorSystem type, suggest adding it:
5489
+ // FIXME(distributed): use getDistributedActorSystemType(nominal); once merged
5490
+ auto &C = nominal->getASTContext ();
5491
+ auto DA = C.getDistributedActorDecl ();
5492
+ Type selfType = nominal->getSelfInterfaceType ();
5493
+ auto conformance = nominal->getParentModule ()->lookupConformance (selfType, DA);
5494
+ auto systemTy = conformance.getTypeWitnessByName (selfType, C.Id_ActorSystem );
5495
+
5496
+ if (!systemTy || systemTy->hasError ()) {
5497
+ diags.diagnose (ComplainLoc,
5498
+ diag::distributed_actor_conformance_missing_system_type,
5499
+ nominal->getName ());
5500
+ return ;
5501
+ }
5502
+ }
5503
+
5478
5504
// Special case: for enums with a raw type, explain that the failing
5479
5505
// conformance to RawRepresentable was inferred.
5480
5506
if (auto enumDecl = T->getEnumOrBoundGenericEnum ()) {
0 commit comments