@@ -2287,12 +2287,14 @@ Constraint *ConstraintSystem::selectDisjunction() {
2287
2287
auto cs = this ;
2288
2288
auto minDisjunction = std::min_element (disjunctions.begin (), disjunctions.end (),
2289
2289
[&](Constraint *first, Constraint *second) -> bool {
2290
+ unsigned firstActive = first->countActiveNestedConstraints ();
2291
+ unsigned secondActive = second->countActiveNestedConstraints ();
2290
2292
unsigned firstFavored = first->countFavoredNestedConstraints ();
2291
2293
unsigned secondFavored = second->countFavoredNestedConstraints ();
2292
2294
2293
2295
if (!isOperatorBindOverload (first->getNestedConstraints ().front ()) ||
2294
2296
!isOperatorBindOverload (second->getNestedConstraints ().front ()))
2295
- return first-> countActiveNestedConstraints () < second-> countActiveNestedConstraints () ;
2297
+ return firstActive < secondActive ;
2296
2298
2297
2299
if (firstFavored == secondFavored) {
2298
2300
// Look for additional choices that are "favored"
@@ -2305,17 +2307,19 @@ Constraint *ConstraintSystem::selectDisjunction() {
2305
2307
secondFavored += secondExisting.size ();
2306
2308
}
2307
2309
2308
- firstFavored = firstFavored ? firstFavored : first->countActiveNestedConstraints ();
2309
- secondFavored = secondFavored ? secondFavored : second->countActiveNestedConstraints ();
2310
-
2311
2310
// Everything else equal, choose the disjunction with the greatest
2312
2311
// number of resoved argument types. The number of resolved argument
2313
2312
// types is always zero for disjunctions that don't represent applied
2314
2313
// overloads.
2315
2314
if (firstFavored == secondFavored) {
2316
- return first->countResolvedArgumentTypes (*this ) > second->countResolvedArgumentTypes (*this );
2315
+ if (firstActive != secondActive)
2316
+ return firstActive < secondActive;
2317
+
2318
+ return (first->countResolvedArgumentTypes (*this ) > second->countResolvedArgumentTypes (*this ));
2317
2319
}
2318
2320
2321
+ firstFavored = firstFavored ? firstFavored : firstActive;
2322
+ secondFavored = secondFavored ? secondFavored : secondActive;
2319
2323
return firstFavored < secondFavored;
2320
2324
});
2321
2325
0 commit comments