Skip to content

Commit e98752f

Browse files
committed
DistributedActors: Fix another upcoming request cycle
1 parent ef0376f commit e98752f

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

lib/Sema/DerivedConformance/DerivedConformance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ bool DerivedConformance::derivesProtocolConformance(
104104
if (*derivableKind == KnownDerivableProtocolKind::DistributedActor)
105105
return canDeriveDistributedActor(Nominal, DC);
106106
if (*derivableKind == KnownDerivableProtocolKind::DistributedActorSystem)
107-
return canDeriveDistributedActorSystem(Nominal, DC);
107+
return canDeriveDistributedActorSystem(Conformance);
108108

109109
if (*derivableKind == KnownDerivableProtocolKind::AdditiveArithmetic)
110110
return canDeriveAdditiveArithmetic(Nominal, DC);

lib/Sema/DerivedConformance/DerivedConformance.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ class DerivedConformance {
333333
DeclContext *dc);
334334

335335
/// Whether we can derive the given DistributedActorSystem requirements.
336-
static bool canDeriveDistributedActorSystem(NominalTypeDecl *nominal,
337-
DeclContext *dc);
336+
static bool canDeriveDistributedActorSystem(
337+
NormalProtocolConformance *conformance);
338338

339339
/// Derive a 'DistributedActor' requirement for an distributed actor.
340340
///

lib/Sema/DerivedConformance/DerivedConformanceDistributedActor.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,26 @@ bool DerivedConformance::canDeriveDistributedActor(
5454
}
5555

5656
bool DerivedConformance::canDeriveDistributedActorSystem(
57-
NominalTypeDecl *nominal, DeclContext *dc) {
58-
auto &C = nominal->getASTContext();
57+
NormalProtocolConformance *conformance) {
58+
auto &ctx = conformance->getDeclContext()->getASTContext();
5959

60-
// Make sure ad-hoc requirements that we'll use in synthesis are present, before we try to use them.
61-
// This leads to better error reporting because we already have errors happening (missing witnesses).
62-
if (auto handlerType = getDistributedActorSystemResultHandlerType(nominal)) {
63-
if (!getOnReturnOnDistributedTargetInvocationResultHandler(
64-
handlerType->getAnyNominal()))
65-
return false;
66-
}
60+
if (!ctx.getLoadedModule(ctx.Id_Distributed))
61+
return false;
62+
63+
auto *assocType = conformance->getProtocol()->getAssociatedType(
64+
ctx.Id_ResultHandler);
65+
if (!assocType)
66+
return false;
67+
68+
if (!conformance->hasTypeWitness(assocType))
69+
return false;
70+
71+
auto handlerType = conformance->getTypeWitness(assocType);
72+
if (!getOnReturnOnDistributedTargetInvocationResultHandler(
73+
handlerType->getAnyNominal()))
74+
return false;
6775

68-
return C.getLoadedModule(C.Id_Distributed);
76+
return true;
6977
}
7078

7179
/******************************************************************************/

0 commit comments

Comments
 (0)