@@ -92,14 +92,6 @@ enum class ConstraintKind : char {
92
92
LiteralConformsTo,
93
93
// / A checked cast from the first type to the second.
94
94
CheckedCast,
95
- // / The first type can act as the Self type of the second type (which
96
- // / is a protocol).
97
- // /
98
- // / This constraint is slightly looser than a conforms-to constraint, because
99
- // / an existential can be used as the Self of any protocol within the
100
- // / existential, even if it doesn't conform to that protocol (e.g., due to
101
- // / the use of associated types).
102
- SelfObjectOfProtocol,
103
95
// / Both types are function types. The first function type's
104
96
// / input is the value being passed to the function and its output
105
97
// / is a type variable that describes the output. The second
@@ -344,7 +336,10 @@ enum RememberChoice_t : bool {
344
336
345
337
// / A constraint between two type variables.
346
338
class Constraint final : public llvm::ilist_node<Constraint>,
347
- private llvm::TrailingObjects<Constraint, TypeVariableType *> {
339
+ private llvm::TrailingObjects<Constraint,
340
+ TypeVariableType *,
341
+ ConstraintFix *,
342
+ OverloadChoice> {
348
343
friend TrailingObjects;
349
344
350
345
// / The kind of constraint.
@@ -353,8 +348,8 @@ class Constraint final : public llvm::ilist_node<Constraint>,
353
348
// / The kind of restriction placed on this constraint.
354
349
ConversionRestrictionKind Restriction : 8 ;
355
350
356
- // / The fix to be applied to the constraint before visiting it .
357
- ConstraintFix *TheFix = nullptr ;
351
+ // / Whether we have a fix .
352
+ unsigned HasFix : 1 ;
358
353
359
354
// / Whether the \c Restriction field is valid.
360
355
unsigned HasRestriction : 1 ;
@@ -438,9 +433,6 @@ class Constraint final : public llvm::ilist_node<Constraint>,
438
433
// / The first type
439
434
Type First;
440
435
441
- // / The overload choice
442
- OverloadChoice Choice;
443
-
444
436
// / The DC in which the use appears.
445
437
DeclContext *UseDC;
446
438
} Overload;
@@ -514,6 +506,18 @@ class Constraint final : public llvm::ilist_node<Constraint>,
514
506
return { getTrailingObjects<TypeVariableType *>(), NumTypeVariables };
515
507
}
516
508
509
+ size_t numTrailingObjects (OverloadToken<TypeVariableType *>) const {
510
+ return NumTypeVariables;
511
+ }
512
+
513
+ size_t numTrailingObjects (OverloadToken<ConstraintFix *>) const {
514
+ return HasFix ? 1 : 0 ;
515
+ }
516
+
517
+ size_t numTrailingObjects (OverloadToken<OverloadChoice>) const {
518
+ return Kind == ConstraintKind::BindOverload ? 1 : 0 ;
519
+ }
520
+
517
521
public:
518
522
// / Create a new constraint.
519
523
static Constraint *create (ConstraintSystem &cs, ConstraintKind Kind,
@@ -546,10 +550,10 @@ class Constraint final : public llvm::ilist_node<Constraint>,
546
550
ValueDecl *requirement, DeclContext *useDC,
547
551
FunctionRefKind functionRefKind, ConstraintLocator *locator);
548
552
549
- // / Create an overload-binding constraint.
553
+ // / Create an overload-binding constraint, possibly with a fix .
550
554
static Constraint *createBindOverload (ConstraintSystem &cs, Type type,
551
555
OverloadChoice choice,
552
- DeclContext *useDC,
556
+ DeclContext *useDC, ConstraintFix *fix,
553
557
ConstraintLocator *locator);
554
558
555
559
// / Create a restricted relational constraint.
@@ -563,13 +567,6 @@ class Constraint final : public llvm::ilist_node<Constraint>,
563
567
ConstraintFix *fix, Type first, Type second,
564
568
ConstraintLocator *locator);
565
569
566
- // / Create a bind overload choice with a fix.
567
- // / Note: This constraint is going to be disabled by default.
568
- static Constraint *createFixedChoice (ConstraintSystem &cs, Type type,
569
- OverloadChoice choice,
570
- DeclContext *useDC, ConstraintFix *fix,
571
- ConstraintLocator *locator);
572
-
573
570
// / Create a new disjunction constraint.
574
571
static Constraint *createDisjunction (ConstraintSystem &cs,
575
572
ArrayRef<Constraint *> constraints,
@@ -616,7 +613,11 @@ class Constraint final : public llvm::ilist_node<Constraint>,
616
613
}
617
614
618
615
// / Retrieve the fix associated with this constraint.
619
- ConstraintFix *getFix () const { return TheFix; }
616
+ ConstraintFix *getFix () const {
617
+ if (HasFix)
618
+ return *getTrailingObjects<ConstraintFix *>();
619
+ return nullptr ;
620
+ }
620
621
621
622
// / Whether this constraint is active, i.e., in the worklist.
622
623
bool isActive () const { return IsActive; }
@@ -681,7 +682,6 @@ class Constraint final : public llvm::ilist_node<Constraint>,
681
682
case ConstraintKind::LiteralConformsTo:
682
683
case ConstraintKind::TransitivelyConformsTo:
683
684
case ConstraintKind::CheckedCast:
684
- case ConstraintKind::SelfObjectOfProtocol:
685
685
case ConstraintKind::ApplicableFunction:
686
686
case ConstraintKind::DynamicCallableApplicableFunction:
687
687
case ConstraintKind::BindOverload:
@@ -849,7 +849,7 @@ class Constraint final : public llvm::ilist_node<Constraint>,
849
849
// / Retrieve the overload choice for an overload-binding constraint.
850
850
OverloadChoice getOverloadChoice () const {
851
851
assert (Kind == ConstraintKind::BindOverload);
852
- return Overload. Choice ;
852
+ return *getTrailingObjects<OverloadChoice>() ;
853
853
}
854
854
855
855
// / Retrieve the DC in which the overload was used.
@@ -888,9 +888,6 @@ class Constraint final : public llvm::ilist_node<Constraint>,
888
888
// / Retrieve the locator for this constraint.
889
889
ConstraintLocator *getLocator () const { return Locator; }
890
890
891
- // / Clone the given constraint.
892
- Constraint *clone (ConstraintSystem &cs) const ;
893
-
894
891
// / Print constraint placed on type and constraint properties.
895
892
// /
896
893
// / \c skipLocator skips printing of locators.
0 commit comments