@@ -2281,7 +2281,7 @@ class ConstraintSystem {
22812281 // / constraint system. The second type, if valid, contains the type as it
22822282 // / should appear in actual constraint. This will have unbound generic types
22832283 // / opened, placeholder types converted to type variables, etc.
2284- llvm::MapVector <ASTNode, std::pair<ContextualTypeInfo, Type>> contextualTypes;
2284+ llvm::DenseMap <ASTNode, std::pair<ContextualTypeInfo, Type>> contextualTypes;
22852285
22862286 // / Information about each case label item tracked by the constraint system.
22872287 llvm::SmallMapVector<const CaseLabelItem *, CaseLabelItemInfo, 4 >
@@ -2860,9 +2860,6 @@ class ConstraintSystem {
28602860 // / FIXME: Remove this.
28612861 unsigned numFixes;
28622862
2863- // / The length of \c contextualTypes.
2864- unsigned numContextualTypes;
2865-
28662863 // / The length of \c targets.
28672864 unsigned numTargets;
28682865
@@ -3294,10 +3291,17 @@ class ConstraintSystem {
32943291 }
32953292
32963293 void setContextualInfo (ASTNode node, ContextualTypeInfo info) {
3297- assert (bool (node) && " Expected non-null expression!" );
3298- assert (contextualTypes.count (node) == 0 &&
3299- " Already set this contextual type" );
3300- contextualTypes[node] = {info, Type ()};
3294+ ASSERT (bool (node) && " Expected non-null expression!" );
3295+ bool inserted = contextualTypes.insert ({node, {info, Type ()}}).second ;
3296+ ASSERT (inserted);
3297+
3298+ if (solverState)
3299+ recordChange (SolverTrail::Change::RecordedContextualInfo (node));
3300+ }
3301+
3302+ void removeContextualInfo (ASTNode node) {
3303+ bool erased = contextualTypes.erase (node);
3304+ ASSERT (erased);
33013305 }
33023306
33033307 std::optional<ContextualTypeInfo> getContextualTypeInfo (ASTNode node) const {
0 commit comments