File tree Expand file tree Collapse file tree 4 files changed +10
-8
lines changed Expand file tree Collapse file tree 4 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -469,10 +469,6 @@ class BindingSet {
469469 // / checking.
470470 bool isViable (PotentialBinding &binding, bool isTransitive);
471471
472- explicit operator bool () const {
473- return hasViableBindings () || isDirectHole ();
474- }
475-
476472 // / Determine whether this set has any "viable" (or non-hole) bindings.
477473 // /
478474 // / A viable binding could be - a direct or transitive binding
Original file line number Diff line number Diff line change @@ -1171,7 +1171,7 @@ std::optional<BindingSet> ConstraintSystem::determineBestBindings(
11711171 if (shouldAttemptFixes () && typeVar->getImpl ().canBindToHole ())
11721172 return true ;
11731173
1174- return bool ( bindings);
1174+ return bindings. hasViableBindings () || bindings. isDirectHole ( );
11751175 };
11761176
11771177 // Now let's see if we could infer something for related type
@@ -1198,7 +1198,10 @@ std::optional<BindingSet> ConstraintSystem::determineBestBindings(
11981198 if (!bindings.finalize (true ))
11991199 continue ;
12001200
1201- if (!bindings || !isViable)
1201+ if (!bindings.hasViableBindings () && !bindings.isDirectHole ())
1202+ continue ;
1203+
1204+ if (!isViable)
12021205 continue ;
12031206
12041207 onCandidate (bindings);
Original file line number Diff line number Diff line change @@ -1105,7 +1105,9 @@ static void determineBestChoicesInContext(
11051105 // Simply adding it as a binding won't work because if the second argument
11061106 // is non-optional the overload that returns `T?` would still have a lower
11071107 // score.
1108- if (!bindingSet && isNilCoalescingOperator (disjunction)) {
1108+ if (!bindingSet.hasViableBindings () &&
1109+ !bindingSet.isDirectHole () &&
1110+ isNilCoalescingOperator (disjunction)) {
11091111 auto &cg = cs.getConstraintGraph ();
11101112 if (llvm::any_of (cg[typeVar].getConstraints (),
11111113 [&typeVar](Constraint *constraint) {
Original file line number Diff line number Diff line change @@ -921,7 +921,8 @@ bool ConstraintGraph::contractEdges() {
921921 // us enough information to decided on l-valueness.
922922 if (tyvar1->getImpl ().canBindToInOut ()) {
923923 bool isNotContractable = true ;
924- if (auto bindings = CS.getBindingsFor (tyvar1)) {
924+ auto bindings = CS.getBindingsFor (tyvar1);
925+ if (bindings.hasViableBindings () || bindings.isDirectHole ()) {
925926 // Holes can't be contracted.
926927 if (bindings.isHole ())
927928 continue ;
You can’t perform that action at this time.
0 commit comments