Skip to content

Commit

Permalink
[Runtime] Extend Metadata::dump for existential type metadata.
Browse files Browse the repository at this point in the history
Dump whether it's class bounded, the protocols it contains, and the superclass constraint if there is one.
  • Loading branch information
mikeash committed Oct 30, 2019
1 parent eb8182b commit 7b650c5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions stdlib/public/runtime/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3958,6 +3958,24 @@ void Metadata::dump() const {
printf("Labels: %s.\n", tuple->Labels);
}

if (auto *existential = dyn_cast<ExistentialTypeMetadata>(this)) {
printf("Is class bounded: %s.\n",
existential->isClassBounded() ? "true" : "false");
auto protocols = existential->getProtocols();
bool first = true;
printf("Protocols: ");
for (auto protocol : protocols) {
if (!first)
printf(" & ");
printf("%s", protocol.getName());
first = false;
}
if (auto *superclass = existential->getSuperclassConstraint())
if (auto *contextDescriptor = superclass->getTypeContextDescriptor())
printf("Superclass constraint: %s.\n", contextDescriptor->Name.get());
printf("\n");
}

printf("Generic Args: %p.\n", getGenericArgs());

#if SWIFT_OBJC_INTEROP
Expand Down

0 comments on commit 7b650c5

Please sign in to comment.