Skip to content

Commit 826ba58

Browse files
committed
GSB: More useful EquivalenceClass::dump()
1 parent 930909f commit 826ba58

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2429,6 +2429,13 @@ Type EquivalenceClass::getTypeInContext(GenericSignatureBuilder &builder,
24292429

24302430
void EquivalenceClass::dump(llvm::raw_ostream &out,
24312431
GenericSignatureBuilder *builder) const {
2432+
auto dumpSource = [&](const RequirementSource *source) {
2433+
source->dump(out, &builder->getASTContext().SourceMgr, 4);
2434+
if (source->isDerivedRequirement())
2435+
out << " [derived]";
2436+
out << "\n";
2437+
};
2438+
24322439
out << "Equivalence class represented by "
24332440
<< members.front()->getRepresentative()->getDebugName() << ":\n";
24342441
out << "Members: ";
@@ -2442,29 +2449,41 @@ void EquivalenceClass::dump(llvm::raw_ostream &out,
24422449
for (auto entry : conformsTo) {
24432450
out << " " << entry.first->getNameStr() << "\n";
24442451
for (auto constraint : entry.second) {
2445-
constraint.source->dump(out, &builder->getASTContext().SourceMgr, 4);
2446-
if (constraint.source->isDerivedRequirement())
2447-
out << " [derived]";
2448-
out << "\n";
2452+
dumpSource(constraint.source);
24492453
}
24502454
}
24512455

24522456
out << "Same-type constraints:\n";
24532457
for (auto constraint : sameTypeConstraints) {
24542458
out << " " << constraint.getSubjectDependentType({})
24552459
<< " == " << constraint.value << "\n";
2456-
constraint.source->dump(out, &builder->getASTContext().SourceMgr, 4);
2457-
if (constraint.source->isDerivedRequirement())
2458-
out << " [derived]";
2459-
out << "\n";
2460+
dumpSource(constraint.source);
24602461
}
24612462

2462-
if (concreteType)
2463+
if (concreteType) {
24632464
out << "Concrete type: " << concreteType.getString() << "\n";
2464-
if (superclass)
2465+
for (auto constraint : concreteTypeConstraints) {
2466+
out << " " << constraint.getSubjectDependentType({})
2467+
<< " == " << constraint.value << "\n";
2468+
dumpSource(constraint.source);
2469+
}
2470+
}
2471+
if (superclass) {
24652472
out << "Superclass: " << superclass.getString() << "\n";
2466-
if (layout)
2473+
for (auto constraint : superclassConstraints) {
2474+
out << " " << constraint.getSubjectDependentType({})
2475+
<< " : " << constraint.value << "\n";
2476+
dumpSource(constraint.source);
2477+
}
2478+
}
2479+
if (layout) {
24672480
out << "Layout: " << layout.getString() << "\n";
2481+
for (auto constraint : layoutConstraints) {
2482+
out << " " << constraint.getSubjectDependentType({})
2483+
<< " : " << constraint.value << "\n";
2484+
dumpSource(constraint.source);
2485+
}
2486+
}
24682487

24692488
if (!delayedRequirements.empty()) {
24702489
out << "Delayed requirements:\n";

0 commit comments

Comments
 (0)