@@ -1715,6 +1715,13 @@ class SolutionApplicationTarget {
1715
1715
ContextualTypePurpose contextualPurpose,
1716
1716
TypeLoc convertType, bool isDiscarded);
1717
1717
1718
+ SolutionApplicationTarget (Expr *expr, DeclContext *dc, ExprPattern *pattern,
1719
+ Type patternType)
1720
+ : SolutionApplicationTarget(expr, dc, CTP_ExprPattern, patternType,
1721
+ /* isDiscarded=*/ false ) {
1722
+ setPattern (pattern);
1723
+ }
1724
+
1718
1725
SolutionApplicationTarget (AnyFunctionRef fn)
1719
1726
: SolutionApplicationTarget(fn, fn.getBody()) { }
1720
1727
@@ -1800,6 +1807,12 @@ class SolutionApplicationTarget {
1800
1807
static SolutionApplicationTarget forPropertyWrapperInitializer (
1801
1808
VarDecl *wrappedVar, DeclContext *dc, Expr *initializer);
1802
1809
1810
+ static SolutionApplicationTarget forExprPattern (Expr *expr, DeclContext *dc,
1811
+ ExprPattern *pattern,
1812
+ Type patternTy) {
1813
+ return {expr, dc, pattern, patternTy};
1814
+ }
1815
+
1803
1816
Expr *getAsExpr () const {
1804
1817
switch (kind) {
1805
1818
case Kind::expression:
@@ -1902,6 +1915,12 @@ class SolutionApplicationTarget {
1902
1915
return expression.pattern ;
1903
1916
}
1904
1917
1918
+ ExprPattern *getExprPattern () const {
1919
+ assert (kind == Kind::expression);
1920
+ assert (expression.contextualPurpose == CTP_ExprPattern);
1921
+ return cast<ExprPattern>(expression.pattern );
1922
+ }
1923
+
1905
1924
// / For a pattern initialization target, retrieve the contextual pattern.
1906
1925
ContextualPattern getContextualPattern () const ;
1907
1926
@@ -2022,7 +2041,8 @@ class SolutionApplicationTarget {
2022
2041
assert (kind == Kind::expression);
2023
2042
assert (expression.contextualPurpose == CTP_Initialization ||
2024
2043
expression.contextualPurpose == CTP_ForEachStmt ||
2025
- expression.contextualPurpose == CTP_ForEachSequence);
2044
+ expression.contextualPurpose == CTP_ForEachSequence ||
2045
+ expression.contextualPurpose == CTP_ExprPattern);
2026
2046
expression.pattern = pattern;
2027
2047
}
2028
2048
0 commit comments