@@ -1186,7 +1186,7 @@ class Solution {
1186
1186
llvm::DenseMap<ASTNode, Type> nodeTypes;
1187
1187
1188
1188
// / The key path component types introduced by this solution.
1189
- llvm::DenseMap<std::pair<const KeyPathExpr *, unsigned >, TypeBase * >
1189
+ llvm::DenseMap<std::pair<const KeyPathExpr *, unsigned >, Type >
1190
1190
keyPathComponentTypes;
1191
1191
1192
1192
// / Contextual types introduced by this solution.
@@ -2183,9 +2183,23 @@ class ConstraintSystem {
2183
2183
// / run through various diagnostics passes without actually mutating
2184
2184
// / the types on the nodes.
2185
2185
llvm::MapVector<ASTNode, Type> NodeTypes;
2186
- llvm::DenseMap<std::pair<const KeyPathExpr *, unsigned >, TypeBase *>
2186
+
2187
+ // / The nodes for which we have produced types, along with the prior type
2188
+ // / each node had before introducing this type.
2189
+ llvm::SmallVector<std::pair<ASTNode, Type>, 8 > addedNodeTypes;
2190
+
2191
+ // / Maps components in a key path expression to their type. Needed because
2192
+ // / KeyPathExpr + Index isn't an \c ASTNode and thus can't be stored in \c
2193
+ // / NodeTypes.
2194
+ llvm::DenseMap<std::pair<const KeyPathExpr *, /* component index=*/ unsigned >,
2195
+ Type>
2187
2196
KeyPathComponentTypes;
2188
2197
2198
+ // / Same as \c addedNodeTypes for \c KeyPathComponentTypes.
2199
+ llvm::SmallVector<
2200
+ std::tuple<const KeyPathExpr *, /* component index=*/ unsigned , Type>>
2201
+ addedKeyPathComponentTypes;
2202
+
2189
2203
// / Maps AST entries to their solution application targets.
2190
2204
llvm::MapVector<SolutionApplicationTargetsKey, SolutionApplicationTarget>
2191
2205
solutionApplicationTargets;
@@ -2266,10 +2280,6 @@ class ConstraintSystem {
2266
2280
SmallVector<std::pair<ConstraintLocator *, OpenedArchetypeType *>, 4 >
2267
2281
OpenedExistentialTypes;
2268
2282
2269
- // / The nodes for which we have produced types, along with the prior type
2270
- // / each node had before introducing this type.
2271
- llvm::SmallVector<std::pair<ASTNode, Type>, 8 > addedNodeTypes;
2272
-
2273
2283
// / The set of functions that have been transformed by a result builder.
2274
2284
std::vector<std::pair<AnyFunctionRef, AppliedBuilderTransform>>
2275
2285
resultBuilderTransformed;
@@ -2739,6 +2749,8 @@ class ConstraintSystem {
2739
2749
2740
2750
unsigned numAddedNodeTypes;
2741
2751
2752
+ unsigned numAddedKeyPathComponentTypes;
2753
+
2742
2754
unsigned numDisabledConstraints;
2743
2755
2744
2756
unsigned numFavoredConstraints;
@@ -2954,10 +2966,15 @@ class ConstraintSystem {
2954
2966
// / map is used throughout the expression type checker in order to
2955
2967
// / avoid mutating expressions until we know we have successfully
2956
2968
// / type-checked them.
2957
- void setType (KeyPathExpr *KP, unsigned I, Type T) {
2969
+ void setType (const KeyPathExpr *KP, unsigned I, Type T) {
2958
2970
assert (KP && " Expected non-null key path parameter!" );
2959
2971
assert (T && " Expected non-null type!" );
2960
- KeyPathComponentTypes[std::make_pair (KP, I)] = T.getPointer ();
2972
+
2973
+ Type &entry = KeyPathComponentTypes[{KP, I}];
2974
+ Type oldType = entry;
2975
+ entry = T;
2976
+
2977
+ addedKeyPathComponentTypes.push_back (std::make_tuple (KP, I, oldType));
2961
2978
}
2962
2979
2963
2980
// / Check to see if we have a type for a node.
0 commit comments