Skip to content

Commit 020da92

Browse files
author
Amritpan Kaur
committed
[CSBindings] Prevent binding printing if it not a part of an initial state in ComponentStep or does not contribute to or result from a changed state in TypeVariableStep.
1 parent 8b15088 commit 020da92

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
@@ -5346,7 +5346,12 @@ class ConstraintSystem {
53465346
Type wrapperType, Type paramType, ParamDecl *param, Identifier argLabel,
53475347
ConstraintKind matchKind, ConstraintLocatorBuilder locator);
53485348

5349-
Optional<BindingSet> determineBestBindings();
5349+
/// Determine whether given type variable with its set of bindings is viable
5350+
/// to be attempted on the next step of the solver.
5351+
///
5352+
/// \c isSingle indicates whether this is the only component produced
5353+
/// by "split" step, in which case bindings should not be printed in debug output.
5354+
Optional<BindingSet> determineBestBindings(bool isSingle = false);
53505355

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

lib/Sema/CSBindings.cpp

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

738-
Optional<BindingSet> ConstraintSystem::determineBestBindings() {
738+
Optional<BindingSet> ConstraintSystem::determineBestBindings(bool isSingle) {
739739
// Look for potential type variable bindings.
740740
Optional<BindingSet> bestBindings;
741741
llvm::SmallDenseMap<TypeVariableType *, BindingSet> cache;
@@ -798,7 +798,11 @@ Optional<BindingSet> ConstraintSystem::determineBestBindings() {
798798
continue;
799799

800800
if (isDebugMode()) {
801-
bindings.dump(typeVar, llvm::errs(), solverState->depth * 2);
801+
if (!isSingle) {
802+
bindings.dump(typeVar, llvm::errs(), solverState->depth * 2 + 2);
803+
} else if (isSingle && !bindings.Bindings.empty()) {
804+
bindings.dump(typeVar, llvm::errs(), solverState->depth * 2 + 4);
805+
}
802806
}
803807

804808
// 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
@@ -342,7 +342,7 @@ StepResult ComponentStep::take(bool prevFailed) {
342342

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

0 commit comments

Comments
 (0)