@@ -661,47 +661,39 @@ namespace {
661
661
}
662
662
}
663
663
664
- SmallVector<Constraint *, 4 > favoredConstraints;
665
-
666
- TypeBase *favoredTy = nullptr ;
667
-
668
- // Copy over the existing bindings, dividing the constraints up
669
- // into "favored" and non-favored lists.
670
- for (auto oldConstraint : oldConstraints) {
671
- auto overloadChoice = oldConstraint->getOverloadChoice ();
672
- if (isFavored (overloadChoice.getDecl ())) {
673
- favoredConstraints.push_back (oldConstraint);
674
-
675
- favoredTy = overloadChoice.getDecl ()->
676
- getType ()->getAs <AnyFunctionType>()->
677
- getResult ().getPointer ();
678
- }
679
- }
680
-
681
- if (favoredConstraints.size () == 1 ) {
682
- CS.setFavoredType (expr, favoredTy);
683
- }
684
-
685
664
// If there might be replacement constraints, get them now.
686
665
SmallVector<Constraint *, 4 > replacementConstraints;
687
666
if (createReplacements)
688
667
createReplacements (tyvarType, oldConstraints, replacementConstraints);
689
-
668
+
669
+ // Copy over the existing bindings, dividing the constraints up
670
+ // into "favored" and non-favored lists.
671
+ SmallVector<Constraint *, 4 > favoredConstraints;
672
+ for (auto oldConstraint : oldConstraints)
673
+ if (isFavored (oldConstraint->getOverloadChoice ().getDecl ()))
674
+ favoredConstraints.push_back (oldConstraint);
675
+
690
676
// If we did not find any favored constraints, just introduce
691
677
// the replacement constraints (if they differ).
692
678
if (favoredConstraints.empty ()) {
693
679
if (replacementConstraints.size () > oldConstraints.size ()) {
694
680
// Remove the old constraint.
695
681
CS.removeInactiveConstraint (constraint);
696
-
697
682
CS.addConstraint (
698
683
Constraint::createDisjunction (CS,
699
684
replacementConstraints,
700
685
csLoc));
701
686
}
702
687
break ;
703
688
}
704
-
689
+
690
+ if (favoredConstraints.size () == 1 ) {
691
+ auto overloadChoice = favoredConstraints[0 ]->getOverloadChoice ();
692
+ auto overloadType = overloadChoice.getDecl ()->getType ();
693
+ auto resultType = overloadType->getAs <AnyFunctionType>()->getResult ();
694
+ CS.setFavoredType (expr, resultType.getPointer ());
695
+ }
696
+
705
697
// Remove the original constraint from the inactive constraint
706
698
// list and add the new one.
707
699
CS.removeInactiveConstraint (constraint);
0 commit comments