@@ -2221,6 +2221,9 @@ class ConstraintSystem {
22212221
22222222 // / Maps discovered closures to their types inferred
22232223 // / from declared parameters/result and body.
2224+ // /
2225+ // / This is a MapVector because contractEdges() iterates over it and
2226+ // / may depend on order.
22242227 llvm::MapVector<const ClosureExpr *, FunctionType *> ClosureTypes;
22252228
22262229 // / Maps closures and local functions to the pack expansion expressions they
@@ -2857,9 +2860,6 @@ class ConstraintSystem {
28572860 // / FIXME: Remove this.
28582861 unsigned numFixes;
28592862
2860- // / The length of \c ClosureTypes.
2861- unsigned numInferredClosureTypes;
2862-
28632863 // / The length of \c ImpliedResults.
28642864 unsigned numImpliedResults;
28652865
@@ -3083,10 +3083,18 @@ class ConstraintSystem {
30833083 }
30843084
30853085 void setClosureType (const ClosureExpr *closure, FunctionType *type) {
3086- assert (closure);
3087- assert (type && " Expected non-null type" );
3088- assert (ClosureTypes.count (closure) == 0 && " Cannot reset closure type" );
3089- ClosureTypes.insert ({closure, type});
3086+ ASSERT (closure);
3087+ ASSERT (type);
3088+ bool inserted = ClosureTypes.insert ({closure, type}).second ;
3089+ ASSERT (inserted);
3090+
3091+ if (solverState)
3092+ recordChange (SolverTrail::Change::RecordedClosureType (closure));
3093+ }
3094+
3095+ void removeClosureType (const ClosureExpr *closure) {
3096+ bool erased = ClosureTypes.erase (closure);
3097+ ASSERT (erased);
30903098 }
30913099
30923100 FunctionType *getClosureType (const ClosureExpr *closure) const {
0 commit comments