@@ -1526,6 +1526,10 @@ class Solution {
15261526 // / which informs constraint application.
15271527 llvm::DenseMap<ConstraintLocator *, unsigned > DisjunctionChoices;
15281528
1529+ // / A map from applied disjunction constraints to the corresponding
1530+ // / argument function type.
1531+ llvm::DenseMap<ConstraintLocator *, FunctionType *> AppliedDisjunctions;
1532+
15291533 // / The set of opened types for a given locator.
15301534 llvm::DenseMap<ConstraintLocator *, ArrayRef<OpenedType>> OpenedTypes;
15311535
@@ -2332,7 +2336,7 @@ class ConstraintSystem {
23322336
23332337 // / A map from applied disjunction constraints to the corresponding
23342338 // / argument function type.
2335- llvm::SmallMapVector <ConstraintLocator *, const FunctionType *, 4 >
2339+ llvm::SmallDenseMap <ConstraintLocator *, FunctionType *, 4 >
23362340 AppliedDisjunctions;
23372341
23382342 // / For locators associated with call expressions, the trailing closure
@@ -2879,9 +2883,6 @@ class ConstraintSystem {
28792883 // / FIXME: Remove this.
28802884 unsigned numFixes;
28812885
2882- // / The length of \c AppliedDisjunctions.
2883- unsigned numAppliedDisjunctions;
2884-
28852886 // / The length of \c argumentMatchingChoices.
28862887 unsigned numArgumentMatchingChoices;
28872888
@@ -5325,6 +5326,15 @@ class ConstraintSystem {
53255326 ASSERT (erased);
53265327 }
53275328
5329+ // / Record applied disjunction and add a change to the trail.
5330+ void recordAppliedDisjunction (ConstraintLocator *locator,
5331+ FunctionType *type);
5332+
5333+ // / Undo the above change.
5334+ void removeAppliedDisjunction (ConstraintLocator *locator) {
5335+ bool erased = AppliedDisjunctions.erase (locator);
5336+ ASSERT (erased);
5337+ }
53285338
53295339 // / Filter the set of disjunction terms, keeping only those where the
53305340 // / predicate returns \c true.
@@ -5629,9 +5639,12 @@ class ConstraintSystem {
56295639
56305640 // If the given constraint is an applied disjunction, get the argument function
56315641 // that the disjunction is applied to.
5632- const FunctionType *getAppliedDisjunctionArgumentFunction (const Constraint *disjunction) {
5642+ FunctionType *getAppliedDisjunctionArgumentFunction (const Constraint *disjunction) {
56335643 assert (disjunction->getKind () == ConstraintKind::Disjunction);
5634- return AppliedDisjunctions[disjunction->getLocator ()];
5644+ auto found = AppliedDisjunctions.find (disjunction->getLocator ());
5645+ if (found == AppliedDisjunctions.end ())
5646+ return nullptr ;
5647+ return found->second ;
56355648 }
56365649
56375650 // / The overload sets that have already been resolved along the current path.
0 commit comments