Skip to content

Commit 42ad169

Browse files
xedinktoso
authored andcommitted
[CSApply] Fix distributed thunk requirement check to handle non-parameter/capture base
If distributed memeber is referenced on a base that represents a result of some expression which is not a variable, parameter, or a capture it should always be dispatched via a thunk.
1 parent cd5485e commit 42ad169

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/Sema/CSApply.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7933,12 +7933,16 @@ bool ExprRewriter::requiresDistributedThunk(Expr *base, SourceLoc memberLoc,
79337933
auto *memberDecl = memberRef.getDecl();
79347934
assert(memberDecl);
79357935

7936-
if (auto *FD = dyn_cast<AbstractFunctionDecl>(memberDecl)) {
7936+
if (auto *FD = dyn_cast<FuncDecl>(memberDecl)) {
79377937
if (!(FD->isInstanceMember() && FD->isDistributed()))
79387938
return false;
79397939
} else if (auto *VD = dyn_cast<VarDecl>(memberDecl)) {
79407940
if (!VD->isDistributed())
79417941
return false;
7942+
} else {
7943+
// On 'distributed' methods and computed properties could ever
7944+
// require access via a distributed thunk.
7945+
return false;
79427946
}
79437947

79447948
auto *actor = getReferencedParamOrCapture(
@@ -7950,8 +7954,12 @@ bool ExprRewriter::requiresDistributedThunk(Expr *base, SourceLoc memberLoc,
79507954
return nullptr;
79517955
});
79527956

7957+
// If the base is not a parameter/variable reference or a capture
7958+
// it means that it's a result of some expression which cannot
7959+
// possibly be isolated, so referencing a distributed member on
7960+
// such base always requires a thunk.
79537961
if (!actor)
7954-
return false;
7962+
return true;
79557963

79567964
// If this is a method reference on an potentially isolated
79577965
// actor then it cannot be a remote thunk.

0 commit comments

Comments
 (0)