@@ -7388,28 +7388,18 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
7388
7388
// Look through all value-to-optional promotions to allow
7389
7389
// conversions like Double -> CGFloat?? and vice versa.
7390
7390
// T -> Optional<T>
7391
- if (location.endsWith<LocatorPathElt::OptionalPayload>()) {
7391
+ if (location.endsWith<LocatorPathElt::OptionalPayload>() ||
7392
+ location.endsWith<LocatorPathElt::GenericArgument>()) {
7392
7393
SmallVector<LocatorPathElt, 4> path;
7393
7394
auto anchor = location.getLocatorParts(path);
7394
7395
7395
- // An attempt at Double/CGFloat conversion through
7396
- // optional chaining. This is not supported at the
7397
- // moment because solution application doesn't know
7398
- // how to map Double to/from CGFloat through optionals.
7399
- if (isExpr<OptionalEvaluationExpr>(anchor)) {
7400
- if (!shouldAttemptFixes())
7401
- return getTypeMatchFailure(locator);
7402
-
7403
- conversionsOrFixes.push_back(ContextualMismatch::create(
7404
- *this, nominal1, nominal2, getConstraintLocator(locator)));
7405
- break;
7406
- }
7407
-
7408
- // Drop all of the applied `value-to-optional` promotions.
7396
+ // Drop all of the applied `value-to-optional` and
7397
+ // `optional-to-optional` conversions.
7409
7398
path.erase(llvm::remove_if(
7410
7399
path,
7411
7400
[](const LocatorPathElt &elt) {
7412
- return elt.is<LocatorPathElt::OptionalPayload>();
7401
+ return elt.is<LocatorPathElt::OptionalPayload>() ||
7402
+ elt.is<LocatorPathElt::GenericArgument>();
7413
7403
}),
7414
7404
path.end());
7415
7405
@@ -14813,7 +14803,8 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
14813
14803
simplifyLocator(anchor, path, range);
14814
14804
14815
14805
if (path.empty() || llvm::all_of(path, [](const LocatorPathElt &elt) {
14816
- return elt.is<LocatorPathElt::OptionalPayload>();
14806
+ return elt.is<LocatorPathElt::OptionalPayload>() ||
14807
+ elt.is<LocatorPathElt::GenericArgument>();
14817
14808
})) {
14818
14809
if (auto *expr = getAsExpr(anchor))
14819
14810
if (auto depth = getExprDepth(expr))
0 commit comments