Skip to content

Commit 3ae85ab

Browse files
author
Amritpan Kaur
committed
[CSBindings] Print collection type in type variable attributes.
1 parent 49a852b commit 3ae85ab

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,25 +1669,39 @@ void BindingSet::dump(llvm::raw_ostream &out, unsigned indent) const {
16691669
attributes.push_back("delayed");
16701670
if (isSubtypeOfExistentialType())
16711671
attributes.push_back("subtype_of_existential");
1672+
if (!attributes.empty()) {
1673+
out << "[attributes: ";
1674+
interleave(attributes, out, ", ");
1675+
}
1676+
16721677
auto literalKind = getLiteralForScore();
16731678
if (literalKind != LiteralBindingKind::None) {
1674-
std::string literalAttrStr;
1675-
literalAttrStr.append("[literal: ");
1676-
if (literalKind == LiteralBindingKind::Atom) {
1679+
out << ", [literal: ";
1680+
switch (literalKind) {
1681+
case LiteralBindingKind::Atom: {
16771682
if (auto atomKind = TypeVar->getImpl().getAtomicLiteralKind()) {
1678-
literalAttrStr.append(getAtomLiteralAsString(*atomKind));
1683+
out << getAtomLiteralAsString(*atomKind);
16791684
}
1680-
} else {
1681-
literalAttrStr.append(getLiteralBindingKind(literalKind).str());
1685+
break;
16821686
}
1683-
literalAttrStr.append("]");
1684-
attributes.push_back(std::move(literalAttrStr));
1685-
}
1686-
if (!attributes.empty()) {
1687-
out << "[attributes: ";
1688-
interleave(attributes, out, ", ");
1689-
out << "] ";
1687+
case LiteralBindingKind::Collection: {
1688+
std::vector<std::string> collectionLiterals;
1689+
forEachLiteralRequirement([&](KnownProtocolKind protocolKind) {
1690+
collectionLiterals.push_back(
1691+
getCollectionLiteralAsString(protocolKind));
1692+
});
1693+
interleave(collectionLiterals, out, ", ");
1694+
break;
1695+
}
1696+
case LiteralBindingKind::Float:
1697+
case LiteralBindingKind::None:
1698+
out << getLiteralBindingKind(literalKind).str();
1699+
break;
1700+
}
1701+
out << "]";
16901702
}
1703+
out << "] ";
1704+
16911705
if (involvesTypeVariables()) {
16921706
out << "[involves_type_vars: ";
16931707
interleave(AdjacentVars,

0 commit comments

Comments
 (0)