File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -6114,6 +6114,12 @@ class DisjunctionChoice {
6114
6114
return false ;
6115
6115
}
6116
6116
6117
+ bool isDisfavored () const {
6118
+ if (auto *decl = getOverloadChoiceDecl (Choice))
6119
+ return decl->getAttrs ().hasAttribute <DisfavoredOverloadAttr>();
6120
+ return false ;
6121
+ }
6122
+
6117
6123
bool isBeginningOfPartition () const { return IsBeginningOfPartition; }
6118
6124
6119
6125
// FIXME: All three of the accessors below are required to support
Original file line number Diff line number Diff line change @@ -635,9 +635,30 @@ bool DisjunctionStep::shouldSkip(const DisjunctionChoice &choice) const {
635
635
if (choice.isDisabled ())
636
636
return skip (" disabled" );
637
637
638
- // Skip unavailable overloads (unless in diagnostic mode).
639
- if (choice.isUnavailable () && !CS.shouldAttemptFixes ())
640
- return skip (" unavailable" );
638
+ if (!CS.shouldAttemptFixes ()) {
639
+ // Skip unavailable overloads.
640
+ if (choice.isUnavailable ())
641
+ return skip (" unavailable" );
642
+
643
+ // Since the disfavored overloads are always located at the end of
644
+ // the partition they could be skipped if there was at least one
645
+ // valid solution for this partition already, because the solution
646
+ // they produce would always be worse.
647
+ if (choice.isDisfavored () && LastSolvedChoice) {
648
+ bool canSkipDisfavored = true ;
649
+ auto &lastScore = LastSolvedChoice->second ;
650
+ for (unsigned i = 0 , n = unsigned (SK_DisfavoredOverload) + 1 ; i != n;
651
+ ++i) {
652
+ if (lastScore.Data [i] > 0 ) {
653
+ canSkipDisfavored = false ;
654
+ break ;
655
+ }
656
+ }
657
+
658
+ if (canSkipDisfavored)
659
+ return skip (" disfavored" );
660
+ }
661
+ }
641
662
642
663
// If the solver already found a solution with a better overload choice that
643
664
// can be unconditionally substituted by the current choice, skip the current
You can’t perform that action at this time.
0 commit comments