Skip to content

Commit 82bd1b9

Browse files
committed
[CSBindings] Couple of small PotentialBindings cleanups
- Use `int` instead of `unsigned int` to represent # of non-defaultable bindings. Because the formula is `-(Total - Defaultable)` which could only be `0` or negative. - Increase number of defaultable bindings iff the binding is accepted.
1 parent c2d6c9a commit 82bd1b9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ void ConstraintSystem::PotentialBindings::addPotentialBinding(
177177
if (!isViable(binding))
178178
return;
179179

180+
if (binding.isDefaultableBinding())
181+
++NumDefaultableBindings;
182+
180183
Bindings.push_back(std::move(binding));
181184
}
182185

@@ -660,7 +663,6 @@ ConstraintSystem::getPotentialBindings(TypeVariableType *typeVar) {
660663
if (!exactTypes.insert(type->getCanonicalType()).second)
661664
continue;
662665

663-
++result.NumDefaultableBindings;
664666
result.addPotentialBinding({type, AllowedBindingKind::Exact,
665667
constraint->getKind(), nullptr,
666668
constraint->getLocator()});

lib/Sema/ConstraintSystem.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2816,8 +2816,7 @@ class ConstraintSystem {
28162816
};
28172817

28182818
struct PotentialBindings {
2819-
using BindingScore =
2820-
std::tuple<bool, bool, bool, bool, unsigned char, unsigned int>;
2819+
using BindingScore = std::tuple<bool, bool, bool, bool, unsigned char, int>;
28212820

28222821
TypeVariableType *TypeVar;
28232822

0 commit comments

Comments
 (0)