@@ -33,15 +33,13 @@ class ClosureConstraintGenerator
3333
3434 ConstraintSystem &cs;
3535 ClosureExpr *closure;
36- Type closureResultType;
3736
3837public:
3938 // / Whether an error was encountered while generating constraints.
4039 bool hadError = false ;
4140
42- ClosureConstraintGenerator (ConstraintSystem &cs, ClosureExpr *closure,
43- Type closureResultType)
44- : cs(cs), closure(closure), closureResultType(closureResultType) { }
41+ ClosureConstraintGenerator (ConstraintSystem &cs, ClosureExpr *closure)
42+ : cs(cs), closure(closure) {}
4543
4644private:
4745 void visitDecl (Decl *decl) {
@@ -95,11 +93,10 @@ class ClosureConstraintGenerator
9593
9694 // FIXME: Locator should point at the return statement?
9795 bool hasReturn = hasExplicitResult (closure);
98- cs.addConstraint (
99- ConstraintKind::Conversion, cs.getType (expr),
100- closureResultType,
101- cs.getConstraintLocator (
102- closure, LocatorPathElt::ClosureBody (hasReturn)));
96+ cs.addConstraint (ConstraintKind::Conversion, cs.getType (expr),
97+ cs.getClosureType (closure)->getResult (),
98+ cs.getConstraintLocator (
99+ closure, LocatorPathElt::ClosureBody (hasReturn)));
103100 }
104101
105102#define UNSUPPORTED_STMT (STMT ) void visit##STMT##Stmt(STMT##Stmt *) { \
@@ -127,9 +124,8 @@ class ClosureConstraintGenerator
127124
128125}
129126
130- bool ConstraintSystem::generateConstraints (
131- ClosureExpr *closure, Type resultType) {
132- ClosureConstraintGenerator generator (*this , closure, resultType);
127+ bool ConstraintSystem::generateConstraints (ClosureExpr *closure) {
128+ ClosureConstraintGenerator generator (*this , closure);
133129 generator.visit (closure->getBody ());
134130 return generator.hadError ;
135131}
0 commit comments