Skip to content

[Swift Static Mirror] When resolving an external type's conformance, report the underlying type's mangled name #59822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions include/swift/Reflection/TypeRefBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1352,16 +1352,24 @@ class TypeRefBuilder {
(const char *)contextDescriptorFieldAddress,
*contextDescriptorOffset);

// Instead of a type descriptor this may just be a symbol reference, check that first
// Instead of a type descriptor this may just be a reference to an external, check that first
if (auto symbol = OpaqueDynamicSymbolResolver(remote::RemoteAddress(contextTypeDescriptorAddress))) {
if (!symbol->isResolved()) {
mangledTypeName = symbol->getSymbol().str();
Demangle::Context Ctx;
auto demangledRoot =
Ctx.demangleSymbolAsNode(mangledTypeName);
Ctx.demangleSymbolAsNode(symbol->getSymbol().str());
assert(demangledRoot->getKind() == Node::Kind::Global);
typeName =
nodeToString(demangledRoot->getChild(0)->getChild(0));
auto nomTypeDescriptorRoot = demangledRoot->getChild(0);
assert(nomTypeDescriptorRoot->getKind() == Node::Kind::NominalTypeDescriptor);
auto typeRoot = nomTypeDescriptorRoot->getChild(0);
typeName = nodeToString(typeRoot);

auto typeMangling = Demangle::mangleNode(typeRoot);
if (!typeMangling.isSuccess())
mangledTypeName = "";
else
mangledTypeName = typeMangling.result();

return std::make_pair(mangledTypeName, typeName);
} else if (symbol->getOffset()) {
// If symbol is empty and has an offset, this is the resolved remote address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ extension testModAClass : myTestProto {}
// CHECK: CONFORMANCES:
// CHECK: =============
// CHECK-DAG: (__C.testModAClass) : ExternalConformanceCheck.myTestProto
// CHECK-DAG: _$s8testModB0aB7BStructVMn (testModB.testModBStruct) : ExternalConformanceCheck.myTestProto
// CHECK-DAG: 8testModB0aB7BStructV (testModB.testModBStruct) : ExternalConformanceCheck.myTestProto