@@ -1504,6 +1504,9 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
1504
1504
PrintPattern (OS, Indent+2 ).visit (const_cast <Pattern *>(P));
1505
1505
}
1506
1506
void printRec (TypeRepr *T);
1507
+ void printRec (ProtocolConformanceRef conf) {
1508
+ conf.dump (OS, Indent + 2 );
1509
+ }
1507
1510
1508
1511
static const char *getAccessKindString (AccessKind kind) {
1509
1512
switch (kind) {
@@ -1868,6 +1871,10 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
1868
1871
}
1869
1872
void visitErasureExpr (ErasureExpr *E) {
1870
1873
printCommon (E, " erasure_expr" ) << ' \n ' ;
1874
+ for (auto conf : E->getConformances ()) {
1875
+ printRec (conf);
1876
+ OS << ' \n ' ;
1877
+ }
1871
1878
printRec (E->getSubExpr ());
1872
1879
OS << ' )' ;
1873
1880
}
@@ -2385,32 +2392,30 @@ void TypeRepr::dump() const {
2385
2392
}
2386
2393
2387
2394
void Substitution::dump () const {
2388
- llvm::raw_ostream &os = llvm::errs ();
2389
-
2390
- print (os);
2391
- os << ' \n ' ;
2395
+ dump (llvm::errs ());
2396
+ }
2392
2397
2393
- if (!Conformance.size ()) return ;
2398
+ void Substitution::dump (llvm::raw_ostream &out, unsigned indent) const {
2399
+ out.indent (indent);
2400
+ print (out);
2401
+ out << ' \n ' ;
2394
2402
2395
- os << ' [' ;
2396
- bool first = true ;
2397
2403
for (auto &c : Conformance) {
2398
- if (first) {
2399
- first = false ;
2400
- } else {
2401
- os << ' ' ;
2402
- }
2403
- c.dump ();
2404
+ c.dump (out, indent + 2 );
2404
2405
}
2405
- os << " ]" ;
2406
2406
}
2407
2407
2408
2408
void ProtocolConformanceRef::dump () const {
2409
- llvm::raw_ostream &os = llvm::errs ();
2409
+ dump (llvm::errs ());
2410
+ }
2411
+
2412
+ void ProtocolConformanceRef::dump (llvm::raw_ostream &out,
2413
+ unsigned indent) const {
2410
2414
if (isConcrete ()) {
2411
- getConcrete ()->printName (os );
2415
+ getConcrete ()->dump (out, indent );
2412
2416
} else {
2413
- os << " abstract:" << getAbstract ()->getName ();
2417
+ out.indent (indent) << " (abstract_conformance protocol="
2418
+ << getAbstract ()->getName () << ' )' ;
2414
2419
}
2415
2420
}
2416
2421
@@ -2423,10 +2428,45 @@ void swift::dump(const ArrayRef<Substitution> &subs) {
2423
2428
}
2424
2429
2425
2430
void ProtocolConformance::dump () const {
2426
- // FIXME: If we ever write a full print() method for ProtocolConformance, use
2427
- // that.
2428
- printName (llvm::errs ());
2429
- llvm::errs () << ' \n ' ;
2431
+ auto &out = llvm::errs ();
2432
+ dump (out);
2433
+ out << ' \n ' ;
2434
+ }
2435
+
2436
+ void ProtocolConformance::dump (llvm::raw_ostream &out, unsigned indent) const {
2437
+ auto printCommon = [&](StringRef kind) {
2438
+ out.indent (indent) << ' (' << kind << " _conformance type=" << getType ()
2439
+ << " protocol=" << getProtocol ()->getName ();
2440
+ };
2441
+
2442
+ switch (getKind ()) {
2443
+ case ProtocolConformanceKind::Normal:
2444
+ printCommon (" normal" );
2445
+ // Maybe print information about the conforming context?
2446
+ break ;
2447
+
2448
+ case ProtocolConformanceKind::Inherited: {
2449
+ auto conf = cast<InheritedProtocolConformance>(this );
2450
+ printCommon (" inherited" );
2451
+ out << ' \n ' ;
2452
+ conf->getInheritedConformance ()->dump (out, indent + 2 );
2453
+ break ;
2454
+ }
2455
+
2456
+ case ProtocolConformanceKind::Specialized: {
2457
+ auto conf = cast<SpecializedProtocolConformance>(this );
2458
+ printCommon (" specialized" );
2459
+ out << ' \n ' ;
2460
+ for (auto sub : conf->getGenericSubstitutions ()) {
2461
+ sub.dump (out, indent + 2 );
2462
+ out << ' \n ' ;
2463
+ }
2464
+ conf->getGenericConformance ()->dump (out, indent + 2 );
2465
+ break ;
2466
+ }
2467
+ }
2468
+
2469
+ out << ' )' ;
2430
2470
}
2431
2471
2432
2472
// ===----------------------------------------------------------------------===//
0 commit comments