@@ -1766,35 +1766,50 @@ void BindingSet::dump(llvm::raw_ostream &out, unsigned indent) const {
1766
1766
out << " (default type of literal) " ;
1767
1767
break ;
1768
1768
}
1769
- out << BindingType.getString (PO );
1769
+ BindingType.print (out );
1770
1770
}
1771
1771
};
1772
1772
1773
1773
out << " [with possible bindings: " ;
1774
- interleave (Bindings, printBinding, [&]() { out << " ; " ; });
1775
- if (!Literals.empty ()) {
1776
- std::vector<std::string> defaultLiterals;
1777
- for (const auto &literal : Literals) {
1778
- if (literal.second .viableAsBinding ()) {
1779
- auto defaultWithType = " (default type of literal) " +
1780
- literal.second .getDefaultType ().getString (PO);
1781
- defaultLiterals.push_back (defaultWithType);
1782
- }
1774
+ SmallVector<PrintableBinding, 2 > potentialBindings;
1775
+ for (const auto &binding : Bindings) {
1776
+ switch (binding.Kind ) {
1777
+ case AllowedBindingKind::Exact:
1778
+ potentialBindings.push_back (PrintableBinding::exact (binding.BindingType ));
1779
+ break ;
1780
+ case AllowedBindingKind::Supertypes:
1781
+ potentialBindings.push_back (
1782
+ PrintableBinding::supertypesOf (binding.BindingType ));
1783
+ break ;
1784
+ case AllowedBindingKind::Subtypes:
1785
+ potentialBindings.push_back (
1786
+ PrintableBinding::subtypesOf (binding.BindingType ));
1787
+ break ;
1783
1788
}
1784
- interleave (defaultLiterals, out, " , " );
1785
1789
}
1786
- if (Bindings.empty () && Literals.empty ()) {
1790
+ for (const auto &literal : Literals) {
1791
+ if (literal.second .viableAsBinding ()) {
1792
+ potentialBindings.push_back (PrintableBinding::literalDefaultType (
1793
+ literal.second .getDefaultType ()));
1794
+ }
1795
+ }
1796
+ if (potentialBindings.empty ()) {
1787
1797
out << " <empty>" ;
1798
+ } else {
1799
+ interleave (
1800
+ potentialBindings,
1801
+ [&](const PrintableBinding &binding) { binding.print (out, PO); },
1802
+ [&] { out << " , " ; });
1788
1803
}
1789
1804
out << " ]" ;
1790
1805
1791
1806
if (!Defaults.empty ()) {
1792
- out << " [defaults: " ;
1807
+ out << " [defaults: " ;
1793
1808
for (const auto &entry : Defaults) {
1794
1809
auto *constraint = entry.second ;
1795
- PotentialBinding binding{constraint-> getSecondType (),
1796
- AllowedBindingKind::Exact, constraint} ;
1797
- printBinding (binding );
1810
+ auto defaultBinding =
1811
+ PrintableBinding::exact ( constraint-> getSecondType ()) ;
1812
+ defaultBinding. print (out, PO );
1798
1813
}
1799
1814
out << " ]" ;
1800
1815
}
0 commit comments