Skip to content

Commit 3dac2ff

Browse files
author
Amritpan Kaur
committed
[CSStep] Clearly present an initial state of the component step, listing type variables, their possible bindings, and next attempt.
1 parent 19ec12e commit 3dac2ff

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,8 @@ BindingSet::BindingScore BindingSet::formBindingScore(const BindingSet &b) {
735735
-numNonDefaultableBindings);
736736
}
737737

738-
Optional<BindingSet> ConstraintSystem::determineBestBindings() {
738+
Optional<BindingSet>
739+
ConstraintSystem::determineBestBindings() {
739740
// Look for potential type variable bindings.
740741
Optional<BindingSet> bestBindings;
741742
llvm::SmallDenseMap<TypeVariableType *, BindingSet> cache;

lib/Sema/CSStep.cpp

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,13 @@ StepResult ComponentStep::take(bool prevFailed) {
343343
/// Try to figure out what this step is going to be,
344344
/// after the scope has been established.
345345
auto *disjunction = CS.selectDisjunction();
346-
auto bestBindings = CS.determineBestBindings();
346+
const bool isSolverStep = !IsSingle;
347+
auto bestBindings = CS.determineBestBindings(isSolverStep);
348+
if (isSolverStep) {
349+
auto &log = getDebugLogger();
350+
log << ")" << '\n';
351+
log.indent(0);
352+
}
347353

348354
if (CS.shouldAttemptFixes()) {
349355
if ((bestBindings &&
@@ -478,23 +484,6 @@ StepResult ComponentStep::finalize(bool isSuccess) {
478484

479485
void TypeVariableStep::setup() {
480486
++CS.solverState->NumTypeVariablesBound;
481-
if (CS.isDebugMode()) {
482-
PrintOptions PO;
483-
PO.PrintTypesForDebugging = true;
484-
auto &log = getDebugLogger();
485-
486-
auto initialBindings = Producer.getCurrentBindings();
487-
log << "Initial bindings: ";
488-
interleave(
489-
initialBindings.begin(), initialBindings.end(),
490-
[&](const Binding &binding) {
491-
log << TypeVar->getString(PO)
492-
<< " := " << binding.BindingType->getString(PO);
493-
},
494-
[&log] { log << ", "; });
495-
496-
log << '\n';
497-
}
498487
}
499488

500489
bool TypeVariableStep::attempt(const TypeVariableBinding &choice) {

lib/Sema/CSStep.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ class ComponentStep final : public SolverStep {
482482
Type(typeVar).print(log, PO);
483483
},
484484
[&] {
485-
log << ' ';
485+
log << ", ";
486486
});
487487
log << "])" << '\n';
488488

0 commit comments

Comments
 (0)