@@ -36,7 +36,7 @@ class SolverTrail {
36
36
public:
37
37
38
38
// / The kind of change made to the graph.
39
- enum class ChangeKind {
39
+ enum class ChangeKind : unsigned {
40
40
// / Added a new vertex to the constraint graph.
41
41
AddedTypeVariable,
42
42
// / Added a new constraint to the constraint graph.
@@ -53,6 +53,31 @@ class SolverTrail {
53
53
RetractedBindings,
54
54
// / Set the fixed type or parent and flags for a type variable.
55
55
UpdatedTypeVariable,
56
+ // / Recorded a conversion restriction kind.
57
+ AddedConversionRestriction,
58
+ // / Recorded a fix.
59
+ AddedFix,
60
+ // / Recorded a fixed requirement.
61
+ AddedFixedRequirement,
62
+ // / Recorded a disjunction choice.
63
+ RecordedDisjunctionChoice,
64
+ // / Recorded an applied disjunction.
65
+ RecordedAppliedDisjunction,
66
+ // / Recorded an argument matching choice.
67
+ RecordedMatchCallArgumentResult,
68
+ // / Recorded a list of opened types at a locator.
69
+ RecordedOpenedTypes,
70
+ // / Recorded the opening of an existential type at a locator.
71
+ RecordedOpenedExistentialType,
72
+ // / Recorded the opening of a pack existential type.
73
+ RecordedOpenedPackExpansionType,
74
+ // / Recorded the creation of a generic environment for a pack expansion expression.
75
+ RecordedPackExpansionEnvironment,
76
+ // / Recorded the mapping from a pack element expression to its parent
77
+ // / pack expansion expression.
78
+ RecordedPackEnvironment,
79
+ // / Record a defaulted constraint at a locator.
80
+ RecordedDefaultedConstraint,
56
81
};
57
82
58
83
// / A change made to the constraint system.
@@ -64,6 +89,9 @@ class SolverTrail {
64
89
// / The kind of change.
65
90
ChangeKind Kind;
66
91
92
+ // / Extra storage.
93
+ unsigned Options;
94
+
67
95
union {
68
96
TypeVariableType *TypeVar;
69
97
@@ -97,10 +125,26 @@ class SolverTrail {
97
125
98
126
// / The representative of the equivalence class, or the fixed type.
99
127
llvm::PointerUnion<TypeVariableType *, TypeBase *> ParentOrFixed;
100
-
101
- // / The saved value of TypeVariableType::Implementation::getRawOptions().
102
- unsigned Options;
103
128
} Update;
129
+
130
+ struct {
131
+ // / The source type.
132
+ Type SrcType;
133
+
134
+ // / The destination type.
135
+ Type DstType;
136
+ } Restriction;
137
+
138
+ ConstraintFix *Fix;
139
+
140
+ struct {
141
+ GenericTypeParamType *GP;
142
+ Type ReqTy;
143
+ } FixedRequirement;
144
+
145
+ ConstraintLocator *Locator;
146
+ PackExpansionType *ExpansionTy;
147
+ PackElementExpr *ElementExpr;
104
148
};
105
149
106
150
Change () : Kind(ChangeKind::AddedTypeVariable), TypeVar(nullptr ) { }
@@ -137,6 +181,46 @@ class SolverTrail {
137
181
llvm::PointerUnion<TypeVariableType *, TypeBase *> parentOrFixed,
138
182
unsigned options);
139
183
184
+ // / Create a change that recorded a restriction.
185
+ static Change addedConversionRestriction (Type srcType, Type dstType);
186
+
187
+ // / Create a change that recorded a fix.
188
+ static Change addedFix (ConstraintFix *fix);
189
+
190
+ // / Create a change that recorded a fixed requirement.
191
+ static Change addedFixedRequirement (GenericTypeParamType *GP,
192
+ unsigned reqKind,
193
+ Type requirementTy);
194
+
195
+ // / Create a change that recorded a disjunction choice.
196
+ static Change recordedDisjunctionChoice (ConstraintLocator *locator,
197
+ unsigned index);
198
+
199
+ // / Create a change that recorded an applied disjunction.
200
+ static Change recordedAppliedDisjunction (ConstraintLocator *locator);
201
+
202
+ // / Create a change that recorded an applied disjunction.
203
+ static Change recordedMatchCallArgumentResult (ConstraintLocator *locator);
204
+
205
+ // / Create a change that recorded a list of opened types.
206
+ static Change recordedOpenedTypes (ConstraintLocator *locator);
207
+
208
+ // / Create a change that recorded the opening of an existential type.
209
+ static Change recordedOpenedExistentialType (ConstraintLocator *locator);
210
+
211
+ // / Create a change that recorded the opening of a pack expansion type.
212
+ static Change recordedOpenedPackExpansionType (PackExpansionType *expansion);
213
+
214
+ // / Create a change that recorded the opening of a pack expansion type.
215
+ static Change recordedPackExpansionEnvironment (ConstraintLocator *locator);
216
+
217
+ // / Create a change that recorded a mapping from a pack element expression
218
+ // / to its parent expansion expression.
219
+ static Change recordedPackEnvironment (PackElementExpr *packElement);
220
+
221
+ // / Create a change that recorded a defaulted constraint at a locator.
222
+ static Change recordedDefaultedConstraint (ConstraintLocator *locator);
223
+
140
224
// / Undo this change, reverting the constraint graph to the state it
141
225
// / had prior to this change.
142
226
// /
0 commit comments