Skip to content

Commit 1d297d1

Browse files
committed
[AST] Distributed: Mangle protocol requirement accessors with special $ mangling
This way distributed thunks could be formed in contexts that don't know what concrete actor they'd be dispatched to on the other side i.e. `distributed` members in protocol extensions should refer to protocol requirement accessors.
1 parent b443266 commit 1d297d1

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3935,22 +3935,21 @@ void ASTMangler::appendDistributedThunk(
39353935
"distributed thunk to mangle must be function decl");
39363936
assert(thunk->getContextKind() == DeclContextKind::AbstractFunctionDecl);
39373937

3938-
auto inProtocolExtensionMangleAsReference =
3938+
auto referenceInProtocolContextOrRequirement =
39393939
[&thunk, asReference]() -> ProtocolDecl * {
3940-
if (!asReference) {
3941-
return nullptr;
3942-
}
3940+
auto *DC = thunk->getDeclContext();
3941+
if (!asReference)
3942+
return dyn_cast_or_null<ProtocolDecl>(DC);
39433943

3944-
if (auto extension = dyn_cast<ExtensionDecl>(thunk->getDeclContext())) {
3944+
if (auto extension = dyn_cast<ExtensionDecl>(DC))
39453945
return dyn_cast_or_null<ProtocolDecl>(extension->getExtendedNominal());
3946-
}
3946+
39473947
return nullptr;
39483948
};
39493949

3950-
if (auto type = inProtocolExtensionMangleAsReference()) {
3951-
appendContext(type->getDeclContext(), thunk->getAlternateModuleName());
3952-
auto baseName = type->getBaseName();
3953-
appendIdentifier(Twine("$", baseName.getIdentifier().str()).str());
3950+
if (auto *P = referenceInProtocolContextOrRequirement()) {
3951+
appendContext(P->getDeclContext(), thunk->getAlternateModuleName());
3952+
appendIdentifier(Twine("$", P->getNameStr()).str());
39543953
appendOperator("C"); // necessary for roundtrip, though we don't use it
39553954
} else {
39563955
appendContextOf(thunk);

0 commit comments

Comments
 (0)