Skip to content

Commit 0cc26cf

Browse files
committed
[AST] Distributed: Make sure that prospective remoteCall declaration is in type context
1 parent 1909b12 commit 0cc26cf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/AST/DistributedDecl.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,10 @@ bool swift::checkDistributedSerializationRequirementIsExactlyCodable(
387387
bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn) const {
388388
auto &C = getASTContext();
389389
auto module = getParentModule();
390+
auto *DC = getDeclContext();
391+
392+
if (!DC->isTypeContext() || !isGeneric())
393+
return false;
390394

391395
// === Check the name
392396
auto callId = isVoidReturn ? C.Id_remoteCallVoid : C.Id_remoteCall;
@@ -398,7 +402,7 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn)
398402
ProtocolDecl *systemProto =
399403
C.getDistributedActorSystemDecl();
400404

401-
auto systemNominal = getDeclContext()->getSelfNominalTypeDecl();
405+
auto systemNominal = DC->getSelfNominalTypeDecl();
402406
auto distSystemConformance = module->lookupConformance(
403407
systemNominal->getDeclaredInterfaceType(), systemProto);
404408

0 commit comments

Comments
 (0)