Skip to content

Commit a2640b7

Browse files
committed
[Constraint system] Finish allowing one to record pattern types.
1 parent db8bf0b commit a2640b7

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lib/Sema/ConstraintSystem.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,7 @@ class ConstraintSystem {
14811481
llvm::DenseMap<const Expr *, TypeBase *> ExprTypes;
14821482
llvm::DenseMap<const TypeLoc *, TypeBase *> TypeLocTypes;
14831483
llvm::DenseMap<const VarDecl *, TypeBase *> VarTypes;
1484+
llvm::DenseMap<const Pattern *, TypeBase *> PatternTypes;
14841485
llvm::DenseMap<std::pair<const KeyPathExpr *, unsigned>, TypeBase *>
14851486
KeyPathComponentTypes;
14861487

@@ -2235,9 +2236,11 @@ class ConstraintSystem {
22352236
ExprTypes[expr] = type.getPointer();
22362237
} else if (auto typeLoc = node.dyn_cast<const TypeLoc *>()) {
22372238
TypeLocTypes[typeLoc] = type.getPointer();
2238-
} else {
2239-
auto var = node.get<const VarDecl *>();
2239+
} else if (auto var = node.dyn_cast<const VarDecl *>()) {
22402240
VarTypes[var] = type.getPointer();
2241+
} else {
2242+
auto pattern = node.get<const Pattern *>();
2243+
PatternTypes[pattern] = type.getPointer();
22412244
}
22422245

22432246
// Record the fact that we ascribed a type to this node.
@@ -2258,9 +2261,11 @@ class ConstraintSystem {
22582261
ExprTypes.erase(expr);
22592262
} else if (auto typeLoc = node.dyn_cast<const TypeLoc *>()) {
22602263
TypeLocTypes.erase(typeLoc);
2261-
} else {
2262-
auto var = node.get<const VarDecl *>();
2264+
} else if (auto var = node.dyn_cast<const VarDecl *>()) {
22632265
VarTypes.erase(var);
2266+
} else {
2267+
auto pattern = node.get<const Pattern *>();
2268+
PatternTypes.erase(pattern);
22642269
}
22652270
}
22662271

@@ -2287,9 +2292,11 @@ class ConstraintSystem {
22872292
return ExprTypes.find(expr) != ExprTypes.end();
22882293
} else if (auto typeLoc = node.dyn_cast<const TypeLoc *>()) {
22892294
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 *>()) {
22922296
return VarTypes.find(var) != VarTypes.end();
2297+
} else {
2298+
auto pattern = node.get<const Pattern *>();
2299+
return PatternTypes.find(pattern) != PatternTypes.end();
22932300
}
22942301
}
22952302

0 commit comments

Comments
 (0)