Skip to content

Commit a5d3dda

Browse files
authored
Merge pull request #27954 from mikeash/better-existential-metadata-dump
[Runtime] Extend Metadata::dump for existential type metadata.
2 parents 33dfb94 + 7b650c5 commit a5d3dda

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

stdlib/public/runtime/Metadata.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3958,6 +3958,24 @@ void Metadata::dump() const {
39583958
printf("Labels: %s.\n", tuple->Labels);
39593959
}
39603960

3961+
if (auto *existential = dyn_cast<ExistentialTypeMetadata>(this)) {
3962+
printf("Is class bounded: %s.\n",
3963+
existential->isClassBounded() ? "true" : "false");
3964+
auto protocols = existential->getProtocols();
3965+
bool first = true;
3966+
printf("Protocols: ");
3967+
for (auto protocol : protocols) {
3968+
if (!first)
3969+
printf(" & ");
3970+
printf("%s", protocol.getName());
3971+
first = false;
3972+
}
3973+
if (auto *superclass = existential->getSuperclassConstraint())
3974+
if (auto *contextDescriptor = superclass->getTypeContextDescriptor())
3975+
printf("Superclass constraint: %s.\n", contextDescriptor->Name.get());
3976+
printf("\n");
3977+
}
3978+
39613979
printf("Generic Args: %p.\n", getGenericArgs());
39623980

39633981
#if SWIFT_OBJC_INTEROP

0 commit comments

Comments
 (0)