File tree Expand file tree Collapse file tree 3 files changed +21
-13
lines changed
lib/Sema/DerivedConformance Expand file tree Collapse file tree 3 files changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ bool DerivedConformance::derivesProtocolConformance(
104
104
if (*derivableKind == KnownDerivableProtocolKind::DistributedActor)
105
105
return canDeriveDistributedActor (Nominal, DC);
106
106
if (*derivableKind == KnownDerivableProtocolKind::DistributedActorSystem)
107
- return canDeriveDistributedActorSystem (Nominal, DC );
107
+ return canDeriveDistributedActorSystem (Conformance );
108
108
109
109
if (*derivableKind == KnownDerivableProtocolKind::AdditiveArithmetic)
110
110
return canDeriveAdditiveArithmetic (Nominal, DC);
Original file line number Diff line number Diff line change @@ -333,8 +333,8 @@ class DerivedConformance {
333
333
DeclContext *dc);
334
334
335
335
// / Whether we can derive the given DistributedActorSystem requirements.
336
- static bool canDeriveDistributedActorSystem (NominalTypeDecl *nominal,
337
- DeclContext *dc );
336
+ static bool canDeriveDistributedActorSystem (
337
+ NormalProtocolConformance *conformance );
338
338
339
339
// / Derive a 'DistributedActor' requirement for an distributed actor.
340
340
// /
Original file line number Diff line number Diff line change @@ -54,18 +54,26 @@ bool DerivedConformance::canDeriveDistributedActor(
54
54
}
55
55
56
56
bool DerivedConformance::canDeriveDistributedActorSystem (
57
- NominalTypeDecl *nominal, DeclContext *dc ) {
58
- auto &C = nominal ->getASTContext ();
57
+ NormalProtocolConformance *conformance ) {
58
+ auto &ctx = conformance-> getDeclContext () ->getASTContext ();
59
59
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 ;
67
75
68
- return C. getLoadedModule (C. Id_Distributed ) ;
76
+ return true ;
69
77
}
70
78
71
79
/* *****************************************************************************/
You can’t perform that action at this time.
0 commit comments