@@ -7392,28 +7392,18 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
73927392 // Look through all value-to-optional promotions to allow
73937393 // conversions like Double -> CGFloat?? and vice versa.
73947394 // T -> Optional<T>
7395- if (location.endsWith<LocatorPathElt::OptionalPayload>()) {
7395+ if (location.endsWith<LocatorPathElt::OptionalPayload>() ||
7396+ location.endsWith<LocatorPathElt::GenericArgument>()) {
73967397 SmallVector<LocatorPathElt, 4> path;
73977398 auto anchor = location.getLocatorParts(path);
73987399
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.
74137402 path.erase(llvm::remove_if(
74147403 path,
74157404 [](const LocatorPathElt &elt) {
7416- return elt.is<LocatorPathElt::OptionalPayload>();
7405+ return elt.is<LocatorPathElt::OptionalPayload>() ||
7406+ elt.is<LocatorPathElt::GenericArgument>();
74177407 }),
74187408 path.end());
74197409
0 commit comments