Merge pull request #60443 from amritpan/improve-solver-step-printing

[ConstraintSystem] Improve solver step printing in the type inference algorithm debug output
This commit is contained in:
Pavel Yaskevich
2022-09-02 15:53:23 -07:00
committed by GitHub
7 changed files with 110 additions and 46 deletions

View File

@@ -3547,10 +3547,28 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
if (isDebugMode()) {
PrintOptions PO;
PO.PrintTypesForDebugging = true;
llvm::errs().indent(solverState ? solverState->getCurrentIndent() : 2)
<< "(overload set choice binding "
<< boundType->getString(PO) << " := "
<< adjustedRefType->getString(PO) << ")\n";
auto &log = llvm::errs();
log.indent(solverState ? solverState->getCurrentIndent() : 2);
log << "(overload set choice binding ";
boundType->print(log, PO);
log << " := ";
adjustedRefType->print(log, PO);
auto openedAtLoc = getOpenedTypes(locator);
if (!openedAtLoc.empty()) {
log << " [";
llvm::interleave(
openedAtLoc.begin(), openedAtLoc.end(),
[&](OpenedType opened) {
opened.second->getImpl().getGenericParameter()->print(log, PO);
log << " := ";
Type(opened.second).print(log, PO);
},
[&]() { log << ", "; });
log << "]";
}
log << ")\n";
}
if (auto *decl = choice.getDeclOrNull()) {