@@ -33,15 +33,13 @@ class ClosureConstraintGenerator
33
33
34
34
ConstraintSystem &cs;
35
35
ClosureExpr *closure;
36
- Type closureResultType;
37
36
38
37
public:
39
38
// / Whether an error was encountered while generating constraints.
40
39
bool hadError = false ;
41
40
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) {}
45
43
46
44
private:
47
45
void visitDecl (Decl *decl) {
@@ -95,11 +93,10 @@ class ClosureConstraintGenerator
95
93
96
94
// FIXME: Locator should point at the return statement?
97
95
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)));
103
100
}
104
101
105
102
#define UNSUPPORTED_STMT (STMT ) void visit##STMT##Stmt(STMT##Stmt *) { \
@@ -127,9 +124,8 @@ class ClosureConstraintGenerator
127
124
128
125
}
129
126
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);
133
129
generator.visit (closure->getBody ());
134
130
return generator.hadError ;
135
131
}
0 commit comments