Skip to content

Commit 49d397c

Browse files
committed
[ConstraintSystem] Make it possible to anchor a target on a pattern
1 parent efa055c commit 49d397c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,7 @@ class SolutionApplicationTargetsKey {
966966
stmtCondElement,
967967
expr,
968968
stmt,
969+
pattern,
969970
patternBindingEntry,
970971
varDecl,
971972
};
@@ -980,6 +981,8 @@ class SolutionApplicationTargetsKey {
980981

981982
const Stmt *stmt;
982983

984+
const Pattern *pattern;
985+
983986
struct PatternBindingEntry {
984987
const PatternBindingDecl *patternBinding;
985988
unsigned index;
@@ -1009,6 +1012,11 @@ class SolutionApplicationTargetsKey {
10091012
storage.stmt = stmt;
10101013
}
10111014

1015+
SolutionApplicationTargetsKey(const Pattern *pattern) {
1016+
kind = Kind::pattern;
1017+
storage.pattern = pattern;
1018+
}
1019+
10121020
SolutionApplicationTargetsKey(
10131021
const PatternBindingDecl *patternBinding, unsigned index) {
10141022
kind = Kind::patternBindingEntry;
@@ -1040,6 +1048,9 @@ class SolutionApplicationTargetsKey {
10401048
case Kind::stmt:
10411049
return lhs.storage.stmt == rhs.storage.stmt;
10421050

1051+
case Kind::pattern:
1052+
return lhs.storage.pattern == rhs.storage.pattern;
1053+
10431054
case Kind::patternBindingEntry:
10441055
return (lhs.storage.patternBindingEntry.patternBinding
10451056
== rhs.storage.patternBindingEntry.patternBinding) &&
@@ -1081,6 +1092,11 @@ class SolutionApplicationTargetsKey {
10811092
DenseMapInfo<unsigned>::getHashValue(static_cast<unsigned>(kind)),
10821093
DenseMapInfo<void *>::getHashValue(storage.stmt));
10831094

1095+
case Kind::pattern:
1096+
return hash_combine(
1097+
DenseMapInfo<unsigned>::getHashValue(static_cast<unsigned>(kind)),
1098+
DenseMapInfo<void *>::getHashValue(storage.pattern));
1099+
10841100
case Kind::patternBindingEntry:
10851101
return hash_combine(
10861102
DenseMapInfo<unsigned>::getHashValue(static_cast<unsigned>(kind)),

0 commit comments

Comments
 (0)