@@ -1435,7 +1435,7 @@ static bool fixMissingArguments(ConstraintSystem &cs, Expr *anchor,
1435
1435
// (which might be anonymous), it's most likely used as a
1436
1436
// tuple e.g. `$0.0`.
1437
1437
Optional<TypeBase *> argumentTuple;
1438
- if (isa<ClosureExpr>(anchor) && isSingleTupleParam (ctx, args)) {
1438
+ if (isSingleTupleParam (ctx, args)) {
1439
1439
auto argType = args.back ().getPlainType ();
1440
1440
// Let's unpack argument tuple into N arguments, this corresponds
1441
1441
// to something like `foo { (bar: (Int, Int)) in }` where `foo`
@@ -1456,24 +1456,26 @@ static bool fixMissingArguments(ConstraintSystem &cs, Expr *anchor,
1456
1456
};
1457
1457
1458
1458
// Something like `foo { x in }` or `foo { $0 }`
1459
- anchor->forEachChildExpr ([&](Expr *expr) -> Expr * {
1460
- if (auto *UDE = dyn_cast<UnresolvedDotExpr>(expr)) {
1461
- if (!isParam (UDE->getBase ()))
1462
- return expr;
1463
-
1464
- auto name = UDE->getName ().getBaseIdentifier ();
1465
- unsigned index = 0 ;
1466
- if (!name.str ().getAsInteger (10 , index) ||
1467
- llvm::any_of (params, [&](const AnyFunctionType::Param ¶m) {
1468
- return param.getLabel () == name;
1469
- })) {
1470
- argumentTuple.emplace (typeVar);
1471
- args.pop_back ();
1472
- return nullptr ;
1459
+ if (isa<ClosureExpr>(anchor)) {
1460
+ anchor->forEachChildExpr ([&](Expr *expr) -> Expr * {
1461
+ if (auto *UDE = dyn_cast<UnresolvedDotExpr>(expr)) {
1462
+ if (!isParam (UDE->getBase ()))
1463
+ return expr;
1464
+
1465
+ auto name = UDE->getName ().getBaseIdentifier ();
1466
+ unsigned index = 0 ;
1467
+ if (!name.str ().getAsInteger (10 , index) ||
1468
+ llvm::any_of (params, [&](const AnyFunctionType::Param ¶m) {
1469
+ return param.getLabel () == name;
1470
+ })) {
1471
+ argumentTuple.emplace (typeVar);
1472
+ args.pop_back ();
1473
+ return nullptr ;
1474
+ }
1473
1475
}
1474
- }
1475
- return expr ;
1476
- });
1476
+ return expr;
1477
+ }) ;
1478
+ }
1477
1479
}
1478
1480
}
1479
1481
0 commit comments