@@ -1677,6 +1677,7 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
1677
1677
if (isSingleTupleParam (ctx, func2Params) &&
1678
1678
canImplodeParams (func1Params)) {
1679
1679
implodeParams (func1Params);
1680
+ increaseScore (SK_FunctionConversion);
1680
1681
} else if (!ctx.isSwiftVersionAtLeast (5 ) &&
1681
1682
isSingleTupleParam (ctx, func1Params) &&
1682
1683
canImplodeParams (func2Params)) {
@@ -1689,6 +1690,7 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
1689
1690
isa<OverloadedDeclRefExpr>(simplified) ||
1690
1691
isa<UnresolvedDeclRefExpr>(simplified))) {
1691
1692
implodeParams (func2Params);
1693
+ increaseScore (SK_FunctionConversion);
1692
1694
}
1693
1695
}
1694
1696
} else if (last->getKind () == ConstraintLocator::PatternMatch &&
@@ -1716,27 +1718,14 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
1716
1718
if (isSingleTupleParam (ctx, func1Params) &&
1717
1719
canImplodeParams (func2Params)) {
1718
1720
implodeParams (func2Params);
1721
+ increaseScore (SK_FunctionConversion);
1719
1722
} else if (isSingleTupleParam (ctx, func2Params) &&
1720
1723
canImplodeParams (func1Params)) {
1721
1724
implodeParams (func1Params);
1725
+ increaseScore (SK_FunctionConversion);
1722
1726
}
1723
1727
}
1724
1728
}
1725
-
1726
- // If we have an anonymous closure e.g. { return }
1727
- // trying an ArgumentConversion to generic function param
1728
- // let's disfavor an attempt to match a function type with
1729
- // a generic parameter e.g. (A) -> B. This should ideally
1730
- // only matches types with no param like () -> B otherwise
1731
- // closure should have an explicity type e.g. { _ in return }
1732
- if (kind == ConstraintKind::ArgumentConversion &&
1733
- func1->getParams ().empty () && func2->getParams ().size () >= 1 ) {
1734
- auto *anchor = locator.trySimplifyToExpr ();
1735
- auto closureExpr = dyn_cast_or_null<ClosureExpr>(anchor);
1736
- if (closureExpr && closureExpr->hasAnonymousClosureVars ()) {
1737
- increaseScore (SK_DisfavoredOverload);
1738
- }
1739
- }
1740
1729
1741
1730
if (shouldAttemptFixes ()) {
1742
1731
auto *anchor = locator.trySimplifyToExpr ();
0 commit comments