[CSStep] NFC: Unify type binding attempt logging

Instead of printing `trying` for type variable and `assuming`
for disjunction choices, unify it so `BindingStep` logs
`attempting {type variable, disjunction choice}`.
This commit is contained in:
Pavel Yaskevich
2018-09-19 18:37:32 -07:00
parent 0c701964dc
commit f9452afa4f
3 changed files with 20 additions and 27 deletions

View File

@@ -360,24 +360,11 @@ void TypeVariableStep::setup() {
bool TypeVariableStep::attempt(const TypeVariableBinding &choice) {
++CS.solverState->NumTypeVariableBindings;
if (isDebugMode()) {
auto &log = getDebugLogger();
log << "(trying ";
choice.print(log, &CS.getASTContext().SourceMgr);
log << '\n';
}
if (choice.hasDefaultedProtocol())
SawFirstLiteralConstraint = true;
// Try to solve the system with typeVar := type
if (!choice.attempt(CS)) {
if (isDebugMode())
getDebugLogger() << ")\n";
return false;
}
return true;
return choice.attempt(CS);
}
StepResult TypeVariableStep::resume(bool prevFailed) {
@@ -387,16 +374,16 @@ StepResult TypeVariableStep::resume(bool prevFailed) {
// that active binding has a solution.
AnySolved |= !prevFailed;
if (isDebugMode())
getDebugLogger() << ")\n";
const auto choice = ActiveChoice->second;
bool shouldStop = shouldStopAfter(ActiveChoice->second);
// Rewind back all of the changes made to constraint system.
ActiveChoice.reset();
if (isDebugMode())
getDebugLogger() << ")\n";
// Let's check if we should stop right before
// attempting any new bindings.
if (shouldStopAfter(choice))
if (shouldStop)
return done(/*isSuccess=*/AnySolved);
// Attempt next type variable binding.
@@ -567,11 +554,5 @@ bool DisjunctionStep::attempt(const DisjunctionChoice &choice) {
}
}
if (!choice.attempt(CS)) {
if (isDebugMode())
getDebugLogger() << ")\n";
return false;
}
return true;
return choice.attempt(CS);
}