@@ -241,11 +241,12 @@ Constraint::Constraint(Type type, OverloadChoice choice, DeclContext *useDC,
241
241
: Kind(ConstraintKind::BindOverload), HasFix(fix != nullptr ), HasRestriction(false ),
242
242
IsActive(false ), IsDisabled(bool (fix)), IsDisabledForPerformance(false ),
243
243
RememberChoice(false ), IsFavored(false ), IsIsolated(false ),
244
- NumTypeVariables(typeVars.size()), Overload{type, choice, useDC},
244
+ NumTypeVariables(typeVars.size()), Overload{type, useDC},
245
245
Locator (locator) {
246
246
std::copy (typeVars.begin (), typeVars.end (), getTypeVariablesBuffer ().begin ());
247
247
if (fix)
248
248
*getTrailingObjects<ConstraintFix *>() = fix;
249
+ *getTrailingObjects<OverloadChoice>() = choice;
249
250
}
250
251
251
252
Constraint::Constraint (ConstraintKind kind,
@@ -838,8 +839,9 @@ Constraint *Constraint::create(ConstraintSystem &cs, ConstraintKind kind,
838
839
second->is <ProtocolType>());
839
840
840
841
// Create the constraint.
841
- auto size = totalSizeToAlloc<TypeVariableType *, ConstraintFix *>(
842
- typeVars.size (), /* hasFix=*/ 0 );
842
+ auto size =
843
+ totalSizeToAlloc<TypeVariableType *, ConstraintFix *, OverloadChoice>(
844
+ typeVars.size (), /* hasFix=*/ 0 , /* hasOverloadChoice=*/ 0 );
843
845
void *mem = cs.getAllocator ().Allocate (size, alignof (Constraint));
844
846
return ::new (mem) Constraint (kind, first, second, locator, typeVars);
845
847
}
@@ -858,8 +860,9 @@ Constraint *Constraint::create(ConstraintSystem &cs, ConstraintKind kind,
858
860
if (third->hasTypeVariable ())
859
861
third->getTypeVariables (typeVars);
860
862
861
- auto size = totalSizeToAlloc<TypeVariableType *, ConstraintFix *>(
862
- typeVars.size (), /* hasFix=*/ 0 );
863
+ auto size =
864
+ totalSizeToAlloc<TypeVariableType *, ConstraintFix *, OverloadChoice>(
865
+ typeVars.size (), /* hasFix=*/ 0 , /* hasOverloadChoice=*/ 0 );
863
866
void *mem = cs.getAllocator ().Allocate (size, alignof (Constraint));
864
867
return ::new (mem) Constraint (kind,
865
868
first, second, third,
@@ -899,8 +902,9 @@ Constraint *Constraint::createMember(ConstraintSystem &cs, ConstraintKind kind,
899
902
second->getTypeVariables (typeVars);
900
903
901
904
// Create the constraint.
902
- auto size = totalSizeToAlloc<TypeVariableType *, ConstraintFix *>(
903
- typeVars.size (), /* hasFix=*/ 0 );
905
+ auto size =
906
+ totalSizeToAlloc<TypeVariableType *, ConstraintFix *, OverloadChoice>(
907
+ typeVars.size (), /* hasFix=*/ 0 , /* hasOverloadChoice=*/ 0 );
904
908
void *mem = cs.getAllocator ().Allocate (size, alignof (Constraint));
905
909
return new (mem) Constraint (kind, first, second, member, useDC,
906
910
functionRefKind, locator, typeVars);
@@ -920,8 +924,9 @@ Constraint *Constraint::createValueWitness(
920
924
second->getTypeVariables (typeVars);
921
925
922
926
// Create the constraint.
923
- auto size = totalSizeToAlloc<TypeVariableType *, ConstraintFix *>(
924
- typeVars.size (), /* hasFix=*/ 0 );
927
+ auto size =
928
+ totalSizeToAlloc<TypeVariableType *, ConstraintFix *, OverloadChoice>(
929
+ typeVars.size (), /* hasFix=*/ 0 , /* hasOverloadChoice=*/ 0 );
925
930
void *mem = cs.getAllocator ().Allocate (size, alignof (Constraint));
926
931
return new (mem) Constraint (kind, first, second, requirement, useDC,
927
932
functionRefKind, locator, typeVars);
@@ -947,8 +952,9 @@ Constraint *Constraint::createRestricted(ConstraintSystem &cs,
947
952
second->getTypeVariables (typeVars);
948
953
949
954
// Create the constraint.
950
- auto size = totalSizeToAlloc<TypeVariableType *, ConstraintFix *>(
951
- typeVars.size (), /* hasFix=*/ 0 );
955
+ auto size =
956
+ totalSizeToAlloc<TypeVariableType *, ConstraintFix *, OverloadChoice>(
957
+ typeVars.size (), /* hasFix=*/ 0 , /* hasOverloadChoice=*/ 0 );
952
958
void *mem = cs.getAllocator ().Allocate (size, alignof (Constraint));
953
959
return new (mem) Constraint (kind, restriction, first, second, locator,
954
960
typeVars);
@@ -965,8 +971,9 @@ Constraint *Constraint::createFixed(ConstraintSystem &cs, ConstraintKind kind,
965
971
second->getTypeVariables (typeVars);
966
972
967
973
// Create the constraint.
968
- auto size = totalSizeToAlloc<TypeVariableType *, ConstraintFix *>(
969
- typeVars.size (), fix ? 1 : 0 );
974
+ auto size =
975
+ totalSizeToAlloc<TypeVariableType *, ConstraintFix *, OverloadChoice>(
976
+ typeVars.size (), fix ? 1 : 0 , /* hasOverloadChoice=*/ 0 );
970
977
void *mem = cs.getAllocator ().Allocate (size, alignof (Constraint));
971
978
return new (mem) Constraint (kind, fix, first, second, locator, typeVars);
972
979
}
@@ -985,8 +992,9 @@ Constraint *Constraint::createFixedChoice(ConstraintSystem &cs, Type type,
985
992
}
986
993
987
994
// Create the constraint.
988
- auto size = totalSizeToAlloc<TypeVariableType *, ConstraintFix *>(
989
- typeVars.size (), fix ? 1 : 0 );
995
+ auto size =
996
+ totalSizeToAlloc<TypeVariableType *, ConstraintFix *, OverloadChoice>(
997
+ typeVars.size (), fix ? 1 : 0 , /* hasOverloadChoice=*/ 1 );
990
998
void *mem = cs.getAllocator ().Allocate (size, alignof (Constraint));
991
999
return new (mem) Constraint (type, choice, useDC, fix, locator, typeVars);
992
1000
}
@@ -1056,8 +1064,9 @@ Constraint *Constraint::createDisjunction(ConstraintSystem &cs,
1056
1064
#endif
1057
1065
1058
1066
// Create the disjunction constraint.
1059
- auto size = totalSizeToAlloc<TypeVariableType *, ConstraintFix *>(
1060
- typeVars.size (), /* hasFix=*/ 0 );
1067
+ auto size =
1068
+ totalSizeToAlloc<TypeVariableType *, ConstraintFix *, OverloadChoice>(
1069
+ typeVars.size (), /* hasFix=*/ 0 , /* hasOverloadChoice=*/ 0 );
1061
1070
void *mem = cs.getAllocator ().Allocate (size, alignof (Constraint));
1062
1071
auto disjunction = new (mem)
1063
1072
Constraint (ConstraintKind::Disjunction, cs.allocateCopy (constraints),
@@ -1076,8 +1085,9 @@ Constraint *Constraint::createConjunction(
1076
1085
// because each have to be solved in isolation.
1077
1086
1078
1087
assert (!constraints.empty () && " Empty conjunction constraint" );
1079
- auto size = totalSizeToAlloc<TypeVariableType *, ConstraintFix *>(
1080
- typeVars.size (), /* hasFix=*/ 0 );
1088
+ auto size =
1089
+ totalSizeToAlloc<TypeVariableType *, ConstraintFix *, OverloadChoice>(
1090
+ typeVars.size (), /* hasFix=*/ 0 , /* hasOverloadChoice=*/ 0 );
1081
1091
void *mem = cs.getAllocator ().Allocate (size, alignof (Constraint));
1082
1092
auto conjunction = new (mem)
1083
1093
Constraint (ConstraintKind::Conjunction, cs.allocateCopy (constraints),
@@ -1097,8 +1107,9 @@ Constraint *Constraint::createApplicableFunction(
1097
1107
calleeType->getTypeVariables (typeVars);
1098
1108
1099
1109
// Create the constraint.
1100
- auto size = totalSizeToAlloc<TypeVariableType *, ConstraintFix *>(
1101
- typeVars.size (), /* hasFix=*/ 0 );
1110
+ auto size =
1111
+ totalSizeToAlloc<TypeVariableType *, ConstraintFix *, OverloadChoice>(
1112
+ typeVars.size (), /* hasFix=*/ 0 , /* hasOverloadChoice=*/ 0 );
1102
1113
void *mem = cs.getAllocator ().Allocate (size, alignof (Constraint));
1103
1114
auto constraint = new (mem) Constraint (
1104
1115
ConstraintKind::ApplicableFunction, argumentFnType, calleeType, locator,
@@ -1140,8 +1151,9 @@ Constraint *Constraint::createSyntacticElement(ConstraintSystem &cs,
1140
1151
if (auto contextTy = context.getType ())
1141
1152
contextTy->getTypeVariables (typeVars);
1142
1153
1143
- auto size = totalSizeToAlloc<TypeVariableType *, ConstraintFix *>(
1144
- typeVars.size (), /* hasFix=*/ 0 );
1154
+ auto size =
1155
+ totalSizeToAlloc<TypeVariableType *, ConstraintFix *, OverloadChoice>(
1156
+ typeVars.size (), /* hasFix=*/ 0 , /* hasOverloadChoice=*/ 0 );
1145
1157
void *mem = cs.getAllocator ().Allocate (size, alignof (Constraint));
1146
1158
return new (mem) Constraint (node, context, isDiscarded, locator, typeVars);
1147
1159
}
0 commit comments