@@ -4404,7 +4404,6 @@ ConstraintSystem::simplifyEscapableFunctionOfConstraint(
4404
4404
return SolutionKind::Unsolved;
4405
4405
};
4406
4406
4407
-
4408
4407
type2 = getFixedTypeRecursive (type2, flags, /* wantRValue=*/ true );
4409
4408
if (auto fn2 = type2->getAs <FunctionType>()) {
4410
4409
// Solve forward by binding the other type variable to the escapable
@@ -4903,6 +4902,34 @@ Type ConstraintSystem::simplifyAppliedOverloads(
4903
4902
break ;
4904
4903
}
4905
4904
4905
+ // Collect the active overload choices.
4906
+ SmallVector<OverloadChoice, 4 > choices;
4907
+ for (auto constraint : disjunction->getNestedConstraints ()) {
4908
+ if (constraint->isDisabled ())
4909
+ continue ;
4910
+ choices.push_back (constraint->getOverloadChoice ());
4911
+ }
4912
+
4913
+ // If we can favor one generic result over another, do so.
4914
+ if (auto favoredChoice = tryOptimizeGenericDisjunction (choices)) {
4915
+ unsigned favoredIndex = favoredChoice - choices.data ();
4916
+ for (auto constraint : disjunction->getNestedConstraints ()) {
4917
+ if (constraint->isDisabled ())
4918
+ continue ;
4919
+
4920
+ if (favoredIndex == 0 ) {
4921
+ if (solverState)
4922
+ solverState->favorConstraint (constraint);
4923
+ else
4924
+ constraint->setFavored ();
4925
+
4926
+ break ;
4927
+ } else {
4928
+ --favoredIndex;
4929
+ }
4930
+ }
4931
+ }
4932
+
4906
4933
// If there was a constraint that we couldn't reason about, don't use the
4907
4934
// results of any common-type computations.
4908
4935
if (hasUnhandledConstraints)
0 commit comments