@@ -166,9 +166,9 @@ Constraint::Constraint(ConstraintKind kind, Type first, Type second,
166
166
}
167
167
168
168
Constraint::Constraint (Type type, OverloadChoice choice, DeclContext *useDC,
169
- ConstraintLocator *locator,
169
+ ConstraintFix *fix, ConstraintLocator *locator,
170
170
ArrayRef<TypeVariableType *> typeVars)
171
- : Kind(ConstraintKind::BindOverload), HasRestriction(false ),
171
+ : Kind(ConstraintKind::BindOverload), TheFix(fix), HasRestriction(false ),
172
172
IsActive(false ), IsDisabled(false ), RememberChoice(false ),
173
173
IsFavored(false ),
174
174
NumTypeVariables(typeVars.size()), Overload{type, choice, useDC},
@@ -639,18 +639,7 @@ Constraint *Constraint::createBindOverload(ConstraintSystem &cs, Type type,
639
639
OverloadChoice choice,
640
640
DeclContext *useDC,
641
641
ConstraintLocator *locator) {
642
- // Collect type variables.
643
- SmallVector<TypeVariableType *, 4 > typeVars;
644
- if (type->hasTypeVariable ())
645
- type->getTypeVariables (typeVars);
646
- if (auto baseType = choice.getBaseType ()) {
647
- baseType->getTypeVariables (typeVars);
648
- }
649
-
650
- // Create the constraint.
651
- unsigned size = totalSizeToAlloc<TypeVariableType*>(typeVars.size ());
652
- void *mem = cs.getAllocator ().Allocate (size, alignof (Constraint));
653
- return new (mem) Constraint (type, choice, useDC, locator, typeVars);
642
+ return createFixedChoice (cs, type, choice, useDC, /* fix=*/ nullptr , locator);
654
643
}
655
644
656
645
Constraint *Constraint::createRestricted (ConstraintSystem &cs,
@@ -690,6 +679,25 @@ Constraint *Constraint::createFixed(ConstraintSystem &cs, ConstraintKind kind,
690
679
return new (mem) Constraint (kind, fix, first, second, locator, typeVars);
691
680
}
692
681
682
+ Constraint *Constraint::createFixedChoice (ConstraintSystem &cs, Type type,
683
+ OverloadChoice choice,
684
+ DeclContext *useDC,
685
+ ConstraintFix *fix,
686
+ ConstraintLocator *locator) {
687
+ // Collect type variables.
688
+ SmallVector<TypeVariableType *, 4 > typeVars;
689
+ if (type->hasTypeVariable ())
690
+ type->getTypeVariables (typeVars);
691
+ if (auto baseType = choice.getBaseType ()) {
692
+ baseType->getTypeVariables (typeVars);
693
+ }
694
+
695
+ // Create the constraint.
696
+ unsigned size = totalSizeToAlloc<TypeVariableType *>(typeVars.size ());
697
+ void *mem = cs.getAllocator ().Allocate (size, alignof (Constraint));
698
+ return new (mem) Constraint (type, choice, useDC, fix, locator, typeVars);
699
+ }
700
+
693
701
Constraint *Constraint::createDisjunction (ConstraintSystem &cs,
694
702
ArrayRef<Constraint *> constraints,
695
703
ConstraintLocator *locator,
0 commit comments