Skip to content

Commit 7c3cb4f

Browse files
author
Amritpan Kaur
committed
[CSBindings] Fix double printing of type variables.
Fix spacing when printing initial Type Variables. Add line break to bindings that print under Potential Bindings.
1 parent 4a02d51 commit 7c3cb4f

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ class TypeVariableType::Implementation {
590590

591591
/// Print the type variable to the given output stream.
592592
void print(llvm::raw_ostream &OS);
593-
593+
594594
private:
595595
StringRef getTypeVariableOptions(TypeVariableOptions TVO) const {
596596
#define ENTRY(Kind, String) case TypeVariableOptions::Kind: return String

lib/Sema/CSBindings.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,9 +1657,11 @@ void BindingSet::dump(llvm::raw_ostream &out, unsigned indent) const {
16571657

16581658
out.indent(indent);
16591659
out << "(";
1660-
if (auto typeVar = getTypeVariable())
1661-
out << "$T" << typeVar->getImpl().getID() << " ";
1662-
1660+
if (auto typeVar = getTypeVariable()) {
1661+
typeVar->print(out, PO);
1662+
out << " ";
1663+
}
1664+
16631665
std::vector<std::string> attributes;
16641666
if (isDirectHole())
16651667
attributes.push_back("hole");
@@ -1722,7 +1724,7 @@ void BindingSet::dump(llvm::raw_ostream &out, unsigned indent) const {
17221724

17231725
auto numDefaultable = getNumViableDefaultableBindings();
17241726
if (numDefaultable > 0)
1725-
out << "#defaultable_bindings: " << numDefaultable << " ";
1727+
out << "[#defaultable_bindings: " << numDefaultable << "] ";
17261728

17271729
auto printBinding = [&](const PotentialBinding &binding) {
17281730
auto type = binding.BindingType;
@@ -1769,9 +1771,9 @@ void BindingSet::dump(llvm::raw_ostream &out, unsigned indent) const {
17691771
AllowedBindingKind::Exact, constraint};
17701772
printBinding(binding);
17711773
}
1772-
out << "] ";
1774+
out << "]";
17731775
}
1774-
out << ")\n";
1776+
out << ")";
17751777
}
17761778

17771779
// Given a possibly-Optional type, return the direct superclass of the

lib/Sema/CSStep.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ StepResult ComponentStep::take(bool prevFailed) {
352352
auto bestBindings = CS.determineBestBindings([&](const BindingSet &bindings) {
353353
if (CS.isDebugMode() && bindings.hasViableBindings()) {
354354
bindings.dump(bos, CS.solverState->getCurrentIndent() + 2);
355+
bos << "\n";
355356
}
356357
});
357358

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,16 +1466,17 @@ void ConstraintSystem::print(raw_ostream &out) const {
14661466
});
14671467
for (auto tv : typeVariables) {
14681468
out.indent(2);
1469-
tv->getImpl().print(out);
14701469
auto rep = getRepresentative(tv);
14711470
if (rep == tv) {
14721471
if (auto fixed = getFixedType(tv)) {
1472+
tv->getImpl().print(out);
14731473
out << " as ";
14741474
Type(fixed).print(out, PO);
14751475
} else {
14761476
const_cast<ConstraintSystem *>(this)->getBindingsFor(tv).dump(out, 1);
14771477
}
14781478
} else {
1479+
tv->getImpl().print(out);
14791480
out << " equivalent to ";
14801481
Type(rep).print(out, PO);
14811482
}

0 commit comments

Comments
 (0)