@@ -65,9 +65,20 @@ using namespace swift;
65
65
/******************************************************************************/
66
66
67
67
// TODO(distributed): make into a request
68
- Type swift::getConcreteReplacementForProtocolActorSystemType(ValueDecl *member) {
69
- auto &C = member->getASTContext();
70
- auto *DC = member->getDeclContext();
68
+ Type swift::getConcreteReplacementForProtocolActorSystemType(
69
+ ValueDecl *anyValue) {
70
+ auto &C = anyValue->getASTContext();
71
+
72
+ // FIXME(distributed): clean this up, we want a method that gets us AS type
73
+ // given any value, but is this the best way?
74
+ DeclContext *DC;
75
+ if (auto nominal = dyn_cast<NominalTypeDecl>(anyValue)) {
76
+ DC = nominal;
77
+ } else if (auto extension = dyn_cast<ExtensionDecl>(anyValue)) {
78
+ DC = extension->getExtendedNominal();
79
+ } else {
80
+ DC = anyValue->getDeclContext();
81
+ }
71
82
auto DA = C.getDistributedActorDecl();
72
83
73
84
// === When declared inside an actor, we can get the type directly
@@ -78,7 +89,7 @@ Type swift::getConcreteReplacementForProtocolActorSystemType(ValueDecl *member)
78
89
/// === Maybe the value is declared in a protocol?
79
90
if (auto protocol = DC->getSelfProtocolDecl()) {
80
91
GenericSignature signature;
81
- if (auto *genericContext = member ->getAsGenericContext()) {
92
+ if (auto *genericContext = anyValue ->getAsGenericContext()) {
82
93
signature = genericContext->getGenericSignature();
83
94
} else {
84
95
signature = DC->getGenericSignatureOfContext();
@@ -312,7 +323,6 @@ Type ASTContext::getAssociatedTypeOfDistributedSystemOfActor(
312
323
/******** Functions on DistributedActorSystem and friends *********************/
313
324
/******************************************************************************/
314
325
315
-
316
326
FuncDecl*
317
327
ASTContext::getDistributedActorArgumentDecodingMethod(NominalTypeDecl *actor) {
318
328
if (!actor->isDistributedActor())
@@ -380,6 +390,20 @@ bool swift::checkDistributedSerializationRequirementIsExactlyCodable(
380
390
std::count(protocols.begin(), protocols.end(), decodable) == 1;
381
391
}
382
392
393
+ llvm::ArrayRef<ValueDecl *>
394
+ AbstractFunctionDecl::getDistributedMethodWitnessedProtocolRequirements() const {
395
+ auto mutableThis = const_cast<AbstractFunctionDecl *>(this);
396
+
397
+ // Only a 'distributed' decl can witness 'distributed' protocol
398
+ if (!isDistributed()) {
399
+ return llvm::ArrayRef<ValueDecl *>();
400
+ }
401
+
402
+ return evaluateOrDefault(
403
+ getASTContext().evaluator,
404
+ GetDistributedMethodWitnessedProtocolRequirements(mutableThis), {});
405
+ }
406
+
383
407
/******************************************************************************/
384
408
/********************* Ad-hoc protocol requirement checks *********************/
385
409
/******************************************************************************/
@@ -1257,11 +1281,7 @@ AbstractFunctionDecl::isDistributedTargetInvocationResultHandlerOnReturn() const
1257
1281
/********************** Distributed Functions *********************************/
1258
1282
/******************************************************************************/
1259
1283
1260
- bool AbstractFunctionDecl::isDistributed() const {
1261
- return getAttrs().hasAttribute<DistributedActorAttr>();
1262
- }
1263
-
1264
- bool AbstractStorageDecl::isDistributed() const {
1284
+ bool ValueDecl::isDistributed() const {
1265
1285
return getAttrs().hasAttribute<DistributedActorAttr>();
1266
1286
}
1267
1287
0 commit comments