@@ -7392,28 +7392,18 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
7392
7392
// Look through all value-to-optional promotions to allow
7393
7393
// conversions like Double -> CGFloat?? and vice versa.
7394
7394
// T -> Optional<T>
7395
- if (location.endsWith<LocatorPathElt::OptionalPayload>()) {
7395
+ if (location.endsWith<LocatorPathElt::OptionalPayload>() ||
7396
+ location.endsWith<LocatorPathElt::GenericArgument>()) {
7396
7397
SmallVector<LocatorPathElt, 4> path;
7397
7398
auto anchor = location.getLocatorParts(path);
7398
7399
7399
- // An attempt at Double/CGFloat conversion through
7400
- // optional chaining. This is not supported at the
7401
- // moment because solution application doesn't know
7402
- // how to map Double to/from CGFloat through optionals.
7403
- if (isExpr<OptionalEvaluationExpr>(anchor)) {
7404
- if (!shouldAttemptFixes())
7405
- return getTypeMatchFailure(locator);
7406
-
7407
- conversionsOrFixes.push_back(ContextualMismatch::create(
7408
- *this, nominal1, nominal2, getConstraintLocator(locator)));
7409
- break;
7410
- }
7411
-
7412
- // Drop all of the applied `value-to-optional` promotions.
7400
+ // Drop all of the applied `value-to-optional` and
7401
+ // `optional-to-optional` conversions.
7413
7402
path.erase(llvm::remove_if(
7414
7403
path,
7415
7404
[](const LocatorPathElt &elt) {
7416
- return elt.is<LocatorPathElt::OptionalPayload>();
7405
+ return elt.is<LocatorPathElt::OptionalPayload>() ||
7406
+ elt.is<LocatorPathElt::GenericArgument>();
7417
7407
}),
7418
7408
path.end());
7419
7409
0 commit comments