@@ -7489,18 +7489,28 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
7489
7489
// Look through all value-to-optional promotions to allow
7490
7490
// conversions like Double -> CGFloat?? and vice versa.
7491
7491
// T -> Optional<T>
7492
- if (location.endsWith<LocatorPathElt::OptionalInjection>() ||
7493
- location.endsWith<LocatorPathElt::GenericArgument>()) {
7492
+ if (location.endsWith<LocatorPathElt::OptionalInjection>()) {
7494
7493
SmallVector<LocatorPathElt, 4> path;
7495
7494
auto anchor = location.getLocatorParts(path);
7496
7495
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.
7499
7510
path.erase(llvm::remove_if(
7500
7511
path,
7501
7512
[](const LocatorPathElt &elt) {
7502
- return elt.is<LocatorPathElt::OptionalInjection>() ||
7503
- elt.is<LocatorPathElt::GenericArgument>();
7513
+ return elt.is<LocatorPathElt::OptionalInjection>();
7504
7514
}),
7505
7515
path.end());
7506
7516
0 commit comments