@@ -118,7 +118,16 @@ SolverTrail::Change::updatedTypeVariable(
118118 result.Kind = ChangeKind::UpdatedTypeVariable;
119119 result.Update .TypeVar = typeVar;
120120 result.Update .ParentOrFixed = parentOrFixed;
121- result.Update .Options = options;
121+ result.Options = options;
122+ return result;
123+ }
124+
125+ SolverTrail::Change
126+ SolverTrail::Change::addedConversionRestriction (Type srcType, Type dstType) {
127+ Change result;
128+ result.Kind = ChangeKind::AddedConversionRestriction;
129+ result.Restriction .SrcType = srcType;
130+ result.Restriction .DstType = dstType;
122131 return result;
123132}
124133
@@ -157,9 +166,14 @@ void SolverTrail::Change::undo(ConstraintSystem &cs) const {
157166 break ;
158167
159168 case ChangeKind::UpdatedTypeVariable:
160- Update.TypeVar ->getImpl ().setRawOptions (Update. Options );
169+ Update.TypeVar ->getImpl ().setRawOptions (Options);
161170 Update.TypeVar ->getImpl ().ParentOrFixed = Update.ParentOrFixed ;
162171 break ;
172+
173+ case ChangeKind::AddedConversionRestriction:
174+ cs.removeConversionRestriction (Restriction.SrcType ,
175+ Restriction.DstType );
176+ break ;
163177 }
164178}
165179
@@ -229,7 +243,7 @@ void SolverTrail::Change::dump(llvm::raw_ostream &out,
229243 out << " )\n " ;
230244 break ;
231245
232- case ChangeKind::UpdatedTypeVariable:
246+ case ChangeKind::UpdatedTypeVariable: {
233247 out << " (updated type variable " ;
234248 Update.TypeVar ->print (out, PO);
235249
@@ -243,7 +257,16 @@ void SolverTrail::Change::dump(llvm::raw_ostream &out,
243257 parentOrFixed.get <TypeBase *>()->print (out, PO);
244258 }
245259 out << " with options 0x" ;
246- out.write_hex (Update.Options );
260+ out.write_hex (Options);
261+ out << " )\n " ;
262+ break ;
263+ }
264+
265+ case ChangeKind::AddedConversionRestriction:
266+ out << " (added restriction with source " ;
267+ Restriction.SrcType ->print (out, PO);
268+ out << " and destination " ;
269+ Restriction.DstType ->print (out, PO);
247270 out << " )\n " ;
248271 break ;
249272 }
0 commit comments