Skip to content

Commit cf8005b

Browse files
committed
[CSGen] Favor CGFloat operator overloads for floating-pointer literal arguments
If argument is a floating-point literal, with newly introduced implicit Double<->CGFloat conversion, sometimes it's better to choose a concrete function/operator overload on `CGFloat` even if it's not a default literal type e.g. `let _: CGFloat = min(1.0, log(<CGFloat value>))` shouldn't form solutions with `Double` arguments since it would result in multiple implicit conversions, it's better to use a `CGFloat` type for the arguments.
1 parent 9197f92 commit cf8005b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/Sema/CSGen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,8 @@ namespace {
414414
// If there is a default type for the literal protocol, check whether
415415
// it is the same as the parameter type.
416416
// Check whether there is a default type to compare against.
417-
if (paramTy->isEqual(defaultType))
417+
if (paramTy->isEqual(defaultType) ||
418+
(defaultType->isDoubleType() && paramTy->isCGFloatType()))
418419
return true;
419420
}
420421
}

0 commit comments

Comments
 (0)