@@ -978,6 +978,7 @@ class SolutionApplicationTargetsKey {
978978 tombstone,
979979 stmtCondElement,
980980 expr,
981+ closure,
981982 stmt,
982983 pattern,
983984 patternBindingEntry,
@@ -1020,6 +1021,11 @@ class SolutionApplicationTargetsKey {
10201021 storage.expr = expr;
10211022 }
10221023
1024+ SolutionApplicationTargetsKey (const ClosureExpr *closure) {
1025+ kind = Kind::closure;
1026+ storage.expr = closure;
1027+ }
1028+
10231029 SolutionApplicationTargetsKey (const Stmt *stmt) {
10241030 kind = Kind::stmt;
10251031 storage.stmt = stmt;
@@ -1056,6 +1062,7 @@ class SolutionApplicationTargetsKey {
10561062 return lhs.storage .stmtCondElement == rhs.storage .stmtCondElement ;
10571063
10581064 case Kind::expr:
1065+ case Kind::closure:
10591066 return lhs.storage .expr == rhs.storage .expr ;
10601067
10611068 case Kind::stmt:
@@ -1096,6 +1103,7 @@ class SolutionApplicationTargetsKey {
10961103 DenseMapInfo<void *>::getHashValue (storage.stmtCondElement ));
10971104
10981105 case Kind::expr:
1106+ case Kind::closure:
10991107 return hash_combine (
11001108 DenseMapInfo<unsigned >::getHashValue (static_cast <unsigned >(kind)),
11011109 DenseMapInfo<void *>::getHashValue (storage.expr ));
@@ -1623,6 +1631,7 @@ class SolutionApplicationTarget {
16231631public:
16241632 enum class Kind {
16251633 expression,
1634+ closure,
16261635 function,
16271636 stmtCondition,
16281637 caseLabelItem,
@@ -1684,6 +1693,14 @@ class SolutionApplicationTarget {
16841693 };
16851694 } expression;
16861695
1696+ struct {
1697+ // / The closure expression being type-checked.
1698+ ClosureExpr *closure;
1699+
1700+ // / The type to which the expression should be converted.
1701+ Type convertType;
1702+ } closure;
1703+
16871704 struct {
16881705 AnyFunctionRef function;
16891706 BraceStmt *body;
@@ -1735,6 +1752,12 @@ class SolutionApplicationTarget {
17351752 setPattern (pattern);
17361753 }
17371754
1755+ SolutionApplicationTarget (ClosureExpr *closure, Type convertType) {
1756+ kind = Kind::closure;
1757+ this ->closure .closure = closure;
1758+ this ->closure .convertType = convertType;
1759+ }
1760+
17381761 SolutionApplicationTarget (AnyFunctionRef fn)
17391762 : SolutionApplicationTarget(fn, fn.getBody()) { }
17401763
@@ -1831,6 +1854,7 @@ class SolutionApplicationTarget {
18311854 case Kind::expression:
18321855 return expression.expression ;
18331856
1857+ case Kind::closure:
18341858 case Kind::function:
18351859 case Kind::stmtCondition:
18361860 case Kind::caseLabelItem:
@@ -1846,6 +1870,9 @@ class SolutionApplicationTarget {
18461870 case Kind::expression:
18471871 return expression.dc ;
18481872
1873+ case Kind::closure:
1874+ return closure.closure ;
1875+
18491876 case Kind::function:
18501877 return function.function .getAsDeclContext ();
18511878
@@ -1934,6 +1961,11 @@ class SolutionApplicationTarget {
19341961 return cast<ExprPattern>(expression.pattern );
19351962 }
19361963
1964+ Type getClosureContextualType () const {
1965+ assert (kind == Kind::closure);
1966+ return closure.convertType ;
1967+ }
1968+
19371969 // / For a pattern initialization target, retrieve the contextual pattern.
19381970 ContextualPattern getContextualPattern () const ;
19391971
@@ -2062,6 +2094,7 @@ class SolutionApplicationTarget {
20622094 Optional<AnyFunctionRef> getAsFunction () const {
20632095 switch (kind) {
20642096 case Kind::expression:
2097+ case Kind::closure:
20652098 case Kind::stmtCondition:
20662099 case Kind::caseLabelItem:
20672100 case Kind::patternBinding:
@@ -2077,6 +2110,7 @@ class SolutionApplicationTarget {
20772110 Optional<StmtCondition> getAsStmtCondition () const {
20782111 switch (kind) {
20792112 case Kind::expression:
2113+ case Kind::closure:
20802114 case Kind::function:
20812115 case Kind::caseLabelItem:
20822116 case Kind::patternBinding:
@@ -2092,6 +2126,7 @@ class SolutionApplicationTarget {
20922126 Optional<CaseLabelItem *> getAsCaseLabelItem () const {
20932127 switch (kind) {
20942128 case Kind::expression:
2129+ case Kind::closure:
20952130 case Kind::function:
20962131 case Kind::stmtCondition:
20972132 case Kind::patternBinding:
@@ -2107,6 +2142,7 @@ class SolutionApplicationTarget {
21072142 PatternBindingDecl *getAsPatternBinding () const {
21082143 switch (kind) {
21092144 case Kind::expression:
2145+ case Kind::closure:
21102146 case Kind::function:
21112147 case Kind::stmtCondition:
21122148 case Kind::caseLabelItem:
@@ -2122,6 +2158,7 @@ class SolutionApplicationTarget {
21222158 VarDecl *getAsUninitializedWrappedVar () const {
21232159 switch (kind) {
21242160 case Kind::expression:
2161+ case Kind::closure:
21252162 case Kind::function:
21262163 case Kind::stmtCondition:
21272164 case Kind::caseLabelItem:
@@ -2137,6 +2174,7 @@ class SolutionApplicationTarget {
21372174 Pattern *getAsUninitializedVar () const {
21382175 switch (kind) {
21392176 case Kind::expression:
2177+ case Kind::closure:
21402178 case Kind::function:
21412179 case Kind::stmtCondition:
21422180 case Kind::caseLabelItem:
@@ -2152,6 +2190,7 @@ class SolutionApplicationTarget {
21522190 Type getTypeOfUninitializedVar () const {
21532191 switch (kind) {
21542192 case Kind::expression:
2193+ case Kind::closure:
21552194 case Kind::function:
21562195 case Kind::stmtCondition:
21572196 case Kind::caseLabelItem:
@@ -2167,6 +2206,7 @@ class SolutionApplicationTarget {
21672206 PatternBindingDecl *getPatternBindingOfUninitializedVar () const {
21682207 switch (kind) {
21692208 case Kind::expression:
2209+ case Kind::closure:
21702210 case Kind::function:
21712211 case Kind::stmtCondition:
21722212 case Kind::caseLabelItem:
@@ -2182,6 +2222,7 @@ class SolutionApplicationTarget {
21822222 unsigned getIndexOfUninitializedVar () const {
21832223 switch (kind) {
21842224 case Kind::expression:
2225+ case Kind::closure:
21852226 case Kind::function:
21862227 case Kind::stmtCondition:
21872228 case Kind::caseLabelItem:
@@ -2210,6 +2251,9 @@ class SolutionApplicationTarget {
22102251 case Kind::expression:
22112252 return expression.expression ->getSourceRange ();
22122253
2254+ case Kind::closure:
2255+ return closure.closure ->getSourceRange ();
2256+
22132257 case Kind::function:
22142258 return function.body ->getSourceRange ();
22152259
@@ -2240,6 +2284,9 @@ class SolutionApplicationTarget {
22402284 case Kind::expression:
22412285 return expression.expression ->getLoc ();
22422286
2287+ case Kind::closure:
2288+ return closure.closure ->getLoc ();
2289+
22432290 case Kind::function:
22442291 return function.function .getLoc ();
22452292
0 commit comments