mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sema: Remove BindingSet::operator bool
This commit is contained in:
@@ -469,10 +469,6 @@ public:
|
||||
/// checking.
|
||||
bool isViable(PotentialBinding &binding, bool isTransitive);
|
||||
|
||||
explicit operator bool() const {
|
||||
return hasViableBindings() || isDirectHole();
|
||||
}
|
||||
|
||||
/// Determine whether this set has any "viable" (or non-hole) bindings.
|
||||
///
|
||||
/// A viable binding could be - a direct or transitive binding
|
||||
|
||||
@@ -1171,7 +1171,7 @@ std::optional<BindingSet> ConstraintSystem::determineBestBindings(
|
||||
if (shouldAttemptFixes() && typeVar->getImpl().canBindToHole())
|
||||
return true;
|
||||
|
||||
return bool(bindings);
|
||||
return bindings.hasViableBindings() || bindings.isDirectHole();
|
||||
};
|
||||
|
||||
// Now let's see if we could infer something for related type
|
||||
@@ -1198,7 +1198,10 @@ std::optional<BindingSet> ConstraintSystem::determineBestBindings(
|
||||
if (!bindings.finalize(true))
|
||||
continue;
|
||||
|
||||
if (!bindings || !isViable)
|
||||
if (!bindings.hasViableBindings() && !bindings.isDirectHole())
|
||||
continue;
|
||||
|
||||
if (!isViable)
|
||||
continue;
|
||||
|
||||
onCandidate(bindings);
|
||||
|
||||
@@ -1105,7 +1105,9 @@ static void determineBestChoicesInContext(
|
||||
// Simply adding it as a binding won't work because if the second argument
|
||||
// is non-optional the overload that returns `T?` would still have a lower
|
||||
// score.
|
||||
if (!bindingSet && isNilCoalescingOperator(disjunction)) {
|
||||
if (!bindingSet.hasViableBindings() &&
|
||||
!bindingSet.isDirectHole() &&
|
||||
isNilCoalescingOperator(disjunction)) {
|
||||
auto &cg = cs.getConstraintGraph();
|
||||
if (llvm::any_of(cg[typeVar].getConstraints(),
|
||||
[&typeVar](Constraint *constraint) {
|
||||
|
||||
@@ -921,7 +921,8 @@ bool ConstraintGraph::contractEdges() {
|
||||
// us enough information to decided on l-valueness.
|
||||
if (tyvar1->getImpl().canBindToInOut()) {
|
||||
bool isNotContractable = true;
|
||||
if (auto bindings = CS.getBindingsFor(tyvar1)) {
|
||||
auto bindings = CS.getBindingsFor(tyvar1);
|
||||
if (bindings.hasViableBindings() || bindings.isDirectHole()) {
|
||||
// Holes can't be contracted.
|
||||
if (bindings.isHole())
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user