[CSOptimizer] Allow matching against CGFloat as a contextual result type

This commit is contained in:
Pavel Yaskevich
2025-02-06 00:22:40 -08:00
parent 6c28cdfb78
commit 899b2bc1e9
3 changed files with 18 additions and 14 deletions

View File

@@ -1056,19 +1056,6 @@ static void determineBestChoicesInContext(
if (canUseContextualResultTypes() &&
(score > 0 || !hasArgumentCandidates)) {
if (llvm::any_of(resultTypes, [&](const Type candidateResultTy) {
// Avoid increasing weight based on CGFloat result type
// match because that could require narrowing conversion
// in the arguments and that is always detrimental.
//
// For example, `has_CGFloat_param(1.0 + 2.0)` should use
// `+(_: Double, _: Double) -> Double` instead of
// `+(_: CGFloat, _: CGFloat) -> CGFloat` which would match
// parameter of `has_CGFloat_param` exactly but use a
// narrowing conversion for both literals.
if (candidateResultTy->lookThroughAllOptionalTypes()
->isCGFloat())
return false;
return scoreCandidateMatch(genericSig, decl,
overloadType->getResult(),
candidateResultTy,