mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #80419 from xedin/revert-pr-79397
Revert "Sema: Allow optional-to-optional CGFloat <-> Double conversion"
This commit is contained in:
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user