@@ -1481,6 +1481,7 @@ class ConstraintSystem {
1481
1481
llvm::DenseMap<const Expr *, TypeBase *> ExprTypes;
1482
1482
llvm::DenseMap<const TypeLoc *, TypeBase *> TypeLocTypes;
1483
1483
llvm::DenseMap<const VarDecl *, TypeBase *> VarTypes;
1484
+ llvm::DenseMap<const Pattern *, TypeBase *> PatternTypes;
1484
1485
llvm::DenseMap<std::pair<const KeyPathExpr *, unsigned >, TypeBase *>
1485
1486
KeyPathComponentTypes;
1486
1487
@@ -2235,9 +2236,11 @@ class ConstraintSystem {
2235
2236
ExprTypes[expr] = type.getPointer ();
2236
2237
} else if (auto typeLoc = node.dyn_cast <const TypeLoc *>()) {
2237
2238
TypeLocTypes[typeLoc] = type.getPointer ();
2238
- } else {
2239
- auto var = node.get <const VarDecl *>();
2239
+ } else if (auto var = node.dyn_cast <const VarDecl *>()) {
2240
2240
VarTypes[var] = type.getPointer ();
2241
+ } else {
2242
+ auto pattern = node.get <const Pattern *>();
2243
+ PatternTypes[pattern] = type.getPointer ();
2241
2244
}
2242
2245
2243
2246
// Record the fact that we ascribed a type to this node.
@@ -2258,9 +2261,11 @@ class ConstraintSystem {
2258
2261
ExprTypes.erase (expr);
2259
2262
} else if (auto typeLoc = node.dyn_cast <const TypeLoc *>()) {
2260
2263
TypeLocTypes.erase (typeLoc);
2261
- } else {
2262
- auto var = node.get <const VarDecl *>();
2264
+ } else if (auto var = node.dyn_cast <const VarDecl *>()) {
2263
2265
VarTypes.erase (var);
2266
+ } else {
2267
+ auto pattern = node.get <const Pattern *>();
2268
+ PatternTypes.erase (pattern);
2264
2269
}
2265
2270
}
2266
2271
@@ -2287,9 +2292,11 @@ class ConstraintSystem {
2287
2292
return ExprTypes.find (expr) != ExprTypes.end ();
2288
2293
} else if (auto typeLoc = node.dyn_cast <const TypeLoc *>()) {
2289
2294
return TypeLocTypes.find (typeLoc) != TypeLocTypes.end ();
2290
- } else {
2291
- auto var = node.get <const VarDecl *>();
2295
+ } else if (auto var = node.dyn_cast <const VarDecl *>()) {
2292
2296
return VarTypes.find (var) != VarTypes.end ();
2297
+ } else {
2298
+ auto pattern = node.get <const Pattern *>();
2299
+ return PatternTypes.find (pattern) != PatternTypes.end ();
2293
2300
}
2294
2301
}
2295
2302
0 commit comments