Skip to content

Commit 3b2dd8c

Browse files
[CSSimplify] Increase the score with SK_FunctionConversion whenever we have to implode parameters to support SE-110 cases
1 parent a65366e commit 3b2dd8c

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,7 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
16771677
if (isSingleTupleParam(ctx, func2Params) &&
16781678
canImplodeParams(func1Params)) {
16791679
implodeParams(func1Params);
1680+
increaseScore(SK_FunctionConversion);
16801681
} else if (!ctx.isSwiftVersionAtLeast(5) &&
16811682
isSingleTupleParam(ctx, func1Params) &&
16821683
canImplodeParams(func2Params)) {
@@ -1689,6 +1690,7 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
16891690
isa<OverloadedDeclRefExpr>(simplified) ||
16901691
isa<UnresolvedDeclRefExpr>(simplified))) {
16911692
implodeParams(func2Params);
1693+
increaseScore(SK_FunctionConversion);
16921694
}
16931695
}
16941696
} else if (last->getKind() == ConstraintLocator::PatternMatch &&
@@ -1716,27 +1718,14 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
17161718
if (isSingleTupleParam(ctx, func1Params) &&
17171719
canImplodeParams(func2Params)) {
17181720
implodeParams(func2Params);
1721+
increaseScore(SK_FunctionConversion);
17191722
} else if (isSingleTupleParam(ctx, func2Params) &&
17201723
canImplodeParams(func1Params)) {
17211724
implodeParams(func1Params);
1725+
increaseScore(SK_FunctionConversion);
17221726
}
17231727
}
17241728
}
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-
}
17401729

17411730
if (shouldAttemptFixes()) {
17421731
auto *anchor = locator.trySimplifyToExpr();

0 commit comments

Comments
 (0)