@@ -1926,9 +1926,13 @@ namespace {
1926
1926
1927
1927
// / Give each parameter in a ClosureExpr a fresh type variable if parameter
1928
1928
// / types were not specified, and return the eventual function type.
1929
- Type getTypeForParameterList (ParameterList *params,
1930
- ConstraintLocatorBuilder locator) {
1931
- for (auto param : *params) {
1929
+ Type getTypeForParameterList (ClosureExpr *closureExpr) {
1930
+ auto *params = closureExpr->getParameters ();
1931
+ for (auto i : indices (params->getArray ())) {
1932
+ auto *param = params->get (i);
1933
+ auto *locator = CS.getConstraintLocator (
1934
+ closureExpr, LocatorPathElt::getTupleElement (i));
1935
+
1932
1936
// If a type was explicitly specified, use its opened type.
1933
1937
if (auto type = param->getTypeLoc ().getType ()) {
1934
1938
// FIXME: Need a better locator for a pattern as a base.
@@ -1940,9 +1944,8 @@ namespace {
1940
1944
}
1941
1945
1942
1946
// Otherwise, create a fresh type variable.
1943
- Type ty = CS.createTypeVariable (CS.getConstraintLocator (locator),
1944
- TVO_CanBindToInOut);
1945
-
1947
+ Type ty = CS.createTypeVariable (locator, TVO_CanBindToInOut);
1948
+
1946
1949
param->setType (ty);
1947
1950
param->setInterfaceType (ty);
1948
1951
}
@@ -2286,12 +2289,7 @@ namespace {
2286
2289
2287
2290
// Give each parameter in a ClosureExpr a fresh type variable if parameter
2288
2291
// types were not specified, and return the eventual function type.
2289
- auto paramTy = getTypeForParameterList (
2290
- expr->getParameters (),
2291
- CS.getConstraintLocator (
2292
- expr,
2293
- LocatorPathElt::getTupleElement (0 )));
2294
-
2292
+ auto paramTy = getTypeForParameterList (expr);
2295
2293
auto extInfo = FunctionType::ExtInfo ();
2296
2294
2297
2295
if (closureCanThrow (expr))
0 commit comments