@@ -491,6 +491,18 @@ class TypeVariableType::Implementation {
491
491
// / literal (represented by `ArrayExpr` and `DictionaryExpr` in AST).
492
492
bool isCollectionLiteralType () const ;
493
493
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
+
494
506
// / Retrieve the representative of the equivalence class to which this
495
507
// / type variable belongs.
496
508
// /
@@ -1952,6 +1964,9 @@ enum class ConstraintSystemFlags {
1952
1964
1953
1965
// / Disable macro expansions.
1954
1966
DisableMacroExpansions = 0x80 ,
1967
+
1968
+ // / Enable old type-checker performance hacks.
1969
+ EnablePerformanceHacks = 0x100 ,
1955
1970
};
1956
1971
1957
1972
// / Options that affect the constraint system as a whole.
@@ -3591,11 +3606,10 @@ class ConstraintSystem {
3591
3606
return Options.contains (ConstraintSystemFlags::ForCodeCompletion);
3592
3607
}
3593
3608
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 .
3596
3611
bool performanceHacksEnabled () const {
3597
- return !getASTContext ()
3598
- .TypeCheckerOpts .DisableConstraintSolverPerformanceHacks ;
3612
+ return Options.contains (ConstraintSystemFlags::EnablePerformanceHacks);
3599
3613
}
3600
3614
3601
3615
// / Log and record the application of the fix. Return true iff any
@@ -5397,8 +5411,12 @@ class ConstraintSystem {
5397
5411
5398
5412
// / Pick a disjunction from the InactiveConstraints list.
5399
5413
// /
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 ();
5402
5420
5403
5421
// / Pick a conjunction from the InactiveConstraints list.
5404
5422
// /
@@ -6098,6 +6116,12 @@ class DisjunctionChoice {
6098
6116
return false ;
6099
6117
}
6100
6118
6119
+ bool isDisfavored () const {
6120
+ if (auto *decl = getOverloadChoiceDecl (Choice))
6121
+ return decl->getAttrs ().hasAttribute <DisfavoredOverloadAttr>();
6122
+ return false ;
6123
+ }
6124
+
6101
6125
bool isBeginningOfPartition () const { return IsBeginningOfPartition; }
6102
6126
6103
6127
// FIXME: All three of the accessors below are required to support
@@ -6332,7 +6356,8 @@ class DisjunctionChoiceProducer : public BindingProducer<DisjunctionChoice> {
6332
6356
public:
6333
6357
using Element = DisjunctionChoice;
6334
6358
6335
- DisjunctionChoiceProducer (ConstraintSystem &cs, Constraint *disjunction)
6359
+ DisjunctionChoiceProducer (ConstraintSystem &cs, Constraint *disjunction,
6360
+ llvm::TinyPtrVector<Constraint *> &favorites)
6336
6361
: BindingProducer(cs, disjunction->shouldRememberChoice ()
6337
6362
? disjunction->getLocator()
6338
6363
: nullptr),
@@ -6342,6 +6367,11 @@ class DisjunctionChoiceProducer : public BindingProducer<DisjunctionChoice> {
6342
6367
assert (disjunction->getKind () == ConstraintKind::Disjunction);
6343
6368
assert (!disjunction->shouldRememberChoice () || disjunction->getLocator ());
6344
6369
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
+
6345
6375
// Order and partition the disjunction choices.
6346
6376
partitionDisjunction (Ordering, PartitionBeginning);
6347
6377
}
@@ -6386,8 +6416,9 @@ class DisjunctionChoiceProducer : public BindingProducer<DisjunctionChoice> {
6386
6416
// Partition the choices in the disjunction into groups that we will
6387
6417
// iterate over in an order appropriate to attempt to stop before we
6388
6418
// 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);
6391
6422
6392
6423
// / Partition the choices in the range \c first to \c last into groups and
6393
6424
// / order the groups in the best order to attempt based on the argument
0 commit comments