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