Merge pull request #80419 from xedin/revert-pr-79397

Revert "Sema: Allow optional-to-optional CGFloat <-> Double conversion"
This commit is contained in:
Pavel Yaskevich
2025-04-02 00:10:23 -07:00
committed by GitHub
5 changed files with 50 additions and 10 deletions

View File

@@ -7489,18 +7489,28 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
// Look through all value-to-optional promotions to allow
// conversions like Double -> CGFloat?? and vice versa.
// T -> Optional<T>
if (location.endsWith<LocatorPathElt::OptionalInjection>() ||
location.endsWith<LocatorPathElt::GenericArgument>()) {
if (location.endsWith<LocatorPathElt::OptionalInjection>()) {
SmallVector<LocatorPathElt, 4> path;
auto anchor = location.getLocatorParts(path);
// Drop all of the applied `value-to-optional` and
// `optional-to-optional` conversions.
// An attempt at Double/CGFloat conversion through
// optional chaining. This is not supported at the
// moment because solution application doesn't know
// how to map Double to/from CGFloat through optionals.
if (isExpr<OptionalEvaluationExpr>(anchor)) {
if (!shouldAttemptFixes())
return getTypeMatchFailure(locator);
conversionsOrFixes.push_back(ContextualMismatch::create(
*this, nominal1, nominal2, getConstraintLocator(locator)));
break;
}
// Drop all of the applied `value-to-optional` promotions.
path.erase(llvm::remove_if(
path,
[](const LocatorPathElt &elt) {
return elt.is<LocatorPathElt::OptionalInjection>() ||
elt.is<LocatorPathElt::GenericArgument>();
return elt.is<LocatorPathElt::OptionalInjection>();
}),
path.end());