@@ -7489,18 +7489,28 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
74897489 // Look through all value-to-optional promotions to allow
74907490 // conversions like Double -> CGFloat?? and vice versa.
74917491 // T -> Optional<T>
7492- if (location.endsWith<LocatorPathElt::OptionalInjection>() ||
7493- location.endsWith<LocatorPathElt::GenericArgument>()) {
7492+ if (location.endsWith<LocatorPathElt::OptionalInjection>()) {
74947493 SmallVector<LocatorPathElt, 4> path;
74957494 auto anchor = location.getLocatorParts(path);
74967495
7497- // Drop all of the applied `value-to-optional` and
7498- // `optional-to-optional` conversions.
7496+ // An attempt at Double/CGFloat conversion through
7497+ // optional chaining. This is not supported at the
7498+ // moment because solution application doesn't know
7499+ // how to map Double to/from CGFloat through optionals.
7500+ if (isExpr<OptionalEvaluationExpr>(anchor)) {
7501+ if (!shouldAttemptFixes())
7502+ return getTypeMatchFailure(locator);
7503+
7504+ conversionsOrFixes.push_back(ContextualMismatch::create(
7505+ *this, nominal1, nominal2, getConstraintLocator(locator)));
7506+ break;
7507+ }
7508+
7509+ // Drop all of the applied `value-to-optional` promotions.
74997510 path.erase(llvm::remove_if(
75007511 path,
75017512 [](const LocatorPathElt &elt) {
7502- return elt.is<LocatorPathElt::OptionalInjection>() ||
7503- elt.is<LocatorPathElt::GenericArgument>();
7513+ return elt.is<LocatorPathElt::OptionalInjection>();
75047514 }),
75057515 path.end());
75067516
0 commit comments