Skip to content

Commit b6d6605

Browse files
author
Amritpan Kaur
committed
[CSBindings] Add indent to binding when it is printed while solving a component produced by split step.
1 parent 66a738f commit b6d6605

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5537,7 +5537,12 @@ class ConstraintSystem {
55375537
Type wrapperType, Type paramType, ParamDecl *param, Identifier argLabel,
55385538
ConstraintKind matchKind, ConstraintLocatorBuilder locator);
55395539

5540-
Optional<BindingSet> determineBestBindings();
5540+
/// Determine whether given type variable with its set of bindings is viable
5541+
/// to be attempted on the next step of the solver.
5542+
///
5543+
/// \c isSingle indicates whether this is the only component produced
5544+
/// by "split" step, in which case bindings should not be printed in debug output.
5545+
Optional<BindingSet> determineBestBindings(bool isSingle = false);
55415546

55425547
/// Get bindings for the given type variable based on current
55435548
/// state of the constraint system.

lib/Sema/CSBindings.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ BindingSet::BindingScore BindingSet::formBindingScore(const BindingSet &b) {
745745
-numNonDefaultableBindings);
746746
}
747747

748-
Optional<BindingSet> ConstraintSystem::determineBestBindings() {
748+
Optional<BindingSet> ConstraintSystem::determineBestBindings(bool isSingle) {
749749
// Look for potential type variable bindings.
750750
Optional<BindingSet> bestBindings;
751751
llvm::SmallDenseMap<TypeVariableType *, BindingSet> cache;
@@ -808,7 +808,11 @@ Optional<BindingSet> ConstraintSystem::determineBestBindings() {
808808
continue;
809809

810810
if (isDebugMode()) {
811-
bindings.dump(typeVar, llvm::errs(), solverState->getCurrentIndent());
811+
if (!isSingle) {
812+
bindings.dump(typeVar, llvm::errs(), solverState->getCurrentIndent() + 2);
813+
} else if (isSingle && !bindings.Bindings.empty()) {
814+
bindings.dump(typeVar, llvm::errs(), solverState->getCurrentIndent() + 4);
815+
}
812816
}
813817

814818
// If these are the first bindings, or they are better than what

lib/Sema/CSStep.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ StepResult ComponentStep::take(bool prevFailed) {
346346

347347
/// Try to figure out what this step is going to be,
348348
/// after the scope has been established.
349-
auto bestBindings = CS.determineBestBindings();
349+
auto bestBindings = CS.determineBestBindings(IsSingle);
350350
auto *disjunction = CS.selectDisjunction();
351351
auto *conjunction = CS.selectConjunction();
352352

0 commit comments

Comments
 (0)