@@ -491,6 +491,18 @@ class TypeVariableType::Implementation {
491491 // / literal (represented by `ArrayExpr` and `DictionaryExpr` in AST).
492492 bool isCollectionLiteralType () const ;
493493
494+ // / Determine whether this type variable represents a literal such
495+ // / as an integer value, a floating-point value with and without a sign.
496+ bool isNumberLiteralType () const ;
497+
498+ // / Determine whether this type variable represents a result type of a
499+ // / function call.
500+ bool isFunctionResult () const ;
501+
502+ // / Determine whether this type variable represents a type of the ternary
503+ // / operator.
504+ bool isTernary () const ;
505+
494506 // / Retrieve the representative of the equivalence class to which this
495507 // / type variable belongs.
496508 // /
@@ -1952,6 +1964,9 @@ enum class ConstraintSystemFlags {
19521964
19531965 // / Disable macro expansions.
19541966 DisableMacroExpansions = 0x80 ,
1967+
1968+ // / Enable old type-checker performance hacks.
1969+ EnablePerformanceHacks = 0x100 ,
19551970};
19561971
19571972// / Options that affect the constraint system as a whole.
@@ -3591,11 +3606,10 @@ class ConstraintSystem {
35913606 return Options.contains (ConstraintSystemFlags::ForCodeCompletion);
35923607 }
35933608
3594- // / Check whether type-checker performance hacks has been explicitly
3595- // / disabled by a flag .
3609+ // / Check whether old type-checker performance hacks has been explicitly
3610+ // / enabled .
35963611 bool performanceHacksEnabled () const {
3597- return !getASTContext ()
3598- .TypeCheckerOpts .DisableConstraintSolverPerformanceHacks ;
3612+ return Options.contains (ConstraintSystemFlags::EnablePerformanceHacks);
35993613 }
36003614
36013615 // / Log and record the application of the fix. Return true iff any
@@ -5397,8 +5411,12 @@ class ConstraintSystem {
53975411
53985412 // / Pick a disjunction from the InactiveConstraints list.
53995413 // /
5400- // / \returns The selected disjunction.
5401- Constraint *selectDisjunction ();
5414+ // / \returns The selected disjunction and a set of it's favored choices.
5415+ std::optional<std::pair<Constraint *, llvm::TinyPtrVector<Constraint *>>>
5416+ selectDisjunction ();
5417+
5418+ // / The old method that is only used when performance hacks are enabled.
5419+ Constraint *selectDisjunctionWithHacks ();
54025420
54035421 // / Pick a conjunction from the InactiveConstraints list.
54045422 // /
@@ -6098,6 +6116,12 @@ class DisjunctionChoice {
60986116 return false ;
60996117 }
61006118
6119+ bool isDisfavored () const {
6120+ if (auto *decl = getOverloadChoiceDecl (Choice))
6121+ return decl->getAttrs ().hasAttribute <DisfavoredOverloadAttr>();
6122+ return false ;
6123+ }
6124+
61016125 bool isBeginningOfPartition () const { return IsBeginningOfPartition; }
61026126
61036127 // FIXME: All three of the accessors below are required to support
@@ -6332,7 +6356,8 @@ class DisjunctionChoiceProducer : public BindingProducer<DisjunctionChoice> {
63326356public:
63336357 using Element = DisjunctionChoice;
63346358
6335- DisjunctionChoiceProducer (ConstraintSystem &cs, Constraint *disjunction)
6359+ DisjunctionChoiceProducer (ConstraintSystem &cs, Constraint *disjunction,
6360+ llvm::TinyPtrVector<Constraint *> &favorites)
63366361 : BindingProducer(cs, disjunction->shouldRememberChoice ()
63376362 ? disjunction->getLocator()
63386363 : nullptr),
@@ -6342,6 +6367,11 @@ class DisjunctionChoiceProducer : public BindingProducer<DisjunctionChoice> {
63426367 assert (disjunction->getKind () == ConstraintKind::Disjunction);
63436368 assert (!disjunction->shouldRememberChoice () || disjunction->getLocator ());
63446369
6370+ // Mark constraints as favored. This information
6371+ // is going to be used by partitioner.
6372+ for (auto *choice : favorites)
6373+ cs.favorConstraint (choice);
6374+
63456375 // Order and partition the disjunction choices.
63466376 partitionDisjunction (Ordering, PartitionBeginning);
63476377 }
@@ -6386,8 +6416,9 @@ class DisjunctionChoiceProducer : public BindingProducer<DisjunctionChoice> {
63866416 // Partition the choices in the disjunction into groups that we will
63876417 // iterate over in an order appropriate to attempt to stop before we
63886418 // have to visit all of the options.
6389- void partitionDisjunction (SmallVectorImpl<unsigned > &Ordering,
6390- SmallVectorImpl<unsigned > &PartitionBeginning);
6419+ void
6420+ partitionDisjunction (SmallVectorImpl<unsigned > &Ordering,
6421+ SmallVectorImpl<unsigned > &PartitionBeginning);
63916422
63926423 // / Partition the choices in the range \c first to \c last into groups and
63936424 // / order the groups in the best order to attempt based on the argument
0 commit comments