@@ -968,6 +968,7 @@ class SolutionApplicationTargetsKey {
968968 stmtCondElement,
969969 expr,
970970 stmt,
971+ pattern,
971972 patternBindingEntry,
972973 varDecl,
973974 };
@@ -982,6 +983,8 @@ class SolutionApplicationTargetsKey {
982983
983984 const Stmt *stmt;
984985
986+ const Pattern *pattern;
987+
985988 struct PatternBindingEntry {
986989 const PatternBindingDecl *patternBinding;
987990 unsigned index;
@@ -1011,6 +1014,11 @@ class SolutionApplicationTargetsKey {
10111014 storage.stmt = stmt;
10121015 }
10131016
1017+ SolutionApplicationTargetsKey (const Pattern *pattern) {
1018+ kind = Kind::pattern;
1019+ storage.pattern = pattern;
1020+ }
1021+
10141022 SolutionApplicationTargetsKey (
10151023 const PatternBindingDecl *patternBinding, unsigned index) {
10161024 kind = Kind::patternBindingEntry;
@@ -1042,6 +1050,9 @@ class SolutionApplicationTargetsKey {
10421050 case Kind::stmt:
10431051 return lhs.storage .stmt == rhs.storage .stmt ;
10441052
1053+ case Kind::pattern:
1054+ return lhs.storage .pattern == rhs.storage .pattern ;
1055+
10451056 case Kind::patternBindingEntry:
10461057 return (lhs.storage .patternBindingEntry .patternBinding
10471058 == rhs.storage .patternBindingEntry .patternBinding ) &&
@@ -1083,6 +1094,11 @@ class SolutionApplicationTargetsKey {
10831094 DenseMapInfo<unsigned >::getHashValue (static_cast <unsigned >(kind)),
10841095 DenseMapInfo<void *>::getHashValue (storage.stmt ));
10851096
1097+ case Kind::pattern:
1098+ return hash_combine (
1099+ DenseMapInfo<unsigned >::getHashValue (static_cast <unsigned >(kind)),
1100+ DenseMapInfo<void *>::getHashValue (storage.pattern ));
1101+
10861102 case Kind::patternBindingEntry:
10871103 return hash_combine (
10881104 DenseMapInfo<unsigned >::getHashValue (static_cast <unsigned >(kind)),
@@ -1701,6 +1717,13 @@ class SolutionApplicationTarget {
17011717 ContextualTypePurpose contextualPurpose,
17021718 TypeLoc convertType, bool isDiscarded);
17031719
1720+ SolutionApplicationTarget (Expr *expr, DeclContext *dc, ExprPattern *pattern,
1721+ Type patternType)
1722+ : SolutionApplicationTarget(expr, dc, CTP_ExprPattern, patternType,
1723+ /* isDiscarded=*/ false ) {
1724+ setPattern (pattern);
1725+ }
1726+
17041727 SolutionApplicationTarget (AnyFunctionRef fn)
17051728 : SolutionApplicationTarget(fn, fn.getBody()) { }
17061729
@@ -1786,6 +1809,12 @@ class SolutionApplicationTarget {
17861809 static SolutionApplicationTarget forPropertyWrapperInitializer (
17871810 VarDecl *wrappedVar, DeclContext *dc, Expr *initializer);
17881811
1812+ static SolutionApplicationTarget forExprPattern (Expr *expr, DeclContext *dc,
1813+ ExprPattern *pattern,
1814+ Type patternTy) {
1815+ return {expr, dc, pattern, patternTy};
1816+ }
1817+
17891818 Expr *getAsExpr () const {
17901819 switch (kind) {
17911820 case Kind::expression:
@@ -1888,6 +1917,12 @@ class SolutionApplicationTarget {
18881917 return expression.pattern ;
18891918 }
18901919
1920+ ExprPattern *getExprPattern () const {
1921+ assert (kind == Kind::expression);
1922+ assert (expression.contextualPurpose == CTP_ExprPattern);
1923+ return cast<ExprPattern>(expression.pattern );
1924+ }
1925+
18911926 // / For a pattern initialization target, retrieve the contextual pattern.
18921927 ContextualPattern getContextualPattern () const ;
18931928
@@ -2008,7 +2043,8 @@ class SolutionApplicationTarget {
20082043 assert (kind == Kind::expression);
20092044 assert (expression.contextualPurpose == CTP_Initialization ||
20102045 expression.contextualPurpose == CTP_ForEachStmt ||
2011- expression.contextualPurpose == CTP_ForEachSequence);
2046+ expression.contextualPurpose == CTP_ForEachSequence ||
2047+ expression.contextualPurpose == CTP_ExprPattern);
20122048 expression.pattern = pattern;
20132049 }
20142050
@@ -5107,6 +5143,15 @@ class ConstraintSystem {
51075143 = FreeTypeVariableBinding::Disallow);
51085144
51095145public:
5146+ // / Pre-check the target, validating any types that occur in it
5147+ // / and folding sequence expressions.
5148+ // /
5149+ // / \param replaceInvalidRefsWithErrors Indicates whether it's allowed
5150+ // / to replace any discovered invalid member references with `ErrorExpr`.
5151+ static bool preCheckTarget (SolutionApplicationTarget &target,
5152+ bool replaceInvalidRefsWithErrors,
5153+ bool leaveClosureBodiesUnchecked);
5154+
51105155 // / Pre-check the expression, validating any types that occur in the
51115156 // / expression and folding sequence expressions.
51125157 // /
0 commit comments