@@ -5474,7 +5474,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
54745474
54755475 if (kind >= ConstraintKind::Subtype &&
54765476 nominal1->getDecl () != nominal2->getDecl () &&
5477- ((nominal1->isCGFloatType () || nominal2->isCGFloatType ()) &&
5477+ ((nominal1->isCGFloat () || nominal2->isCGFloat ()) &&
54785478 (nominal1->isDouble () || nominal2->isDouble ()))) {
54795479 ConstraintLocatorBuilder location{locator};
54805480 // Look through all value-to-optional promotions to allow
@@ -5485,6 +5485,19 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
54855485 SmallVector<LocatorPathElt, 4 > path;
54865486 auto anchor = location.getLocatorParts (path);
54875487
5488+ // An attempt at Double/CGFloat conversion through
5489+ // optional chaining. This is not supported at the
5490+ // moment because solution application doesn't know
5491+ // how to map Double to/from CGFloat through optionals.
5492+ if (isExpr<OptionalEvaluationExpr>(anchor)) {
5493+ if (!shouldAttemptFixes ())
5494+ return getTypeMatchFailure (locator);
5495+
5496+ conversionsOrFixes.push_back (ContextualMismatch::create (
5497+ *this , nominal1, nominal2, getConstraintLocator (locator)));
5498+ break ;
5499+ }
5500+
54885501 // Drop all of the applied `value-to-optional` promotions.
54895502 path.erase (llvm::remove_if (
54905503 path,
@@ -5519,7 +5532,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
55195532 auto isCGFloatInit = [&](ASTNode location) {
55205533 if (auto *call = getAsExpr<CallExpr>(location)) {
55215534 if (auto *typeExpr = dyn_cast<TypeExpr>(call->getFn ())) {
5522- return getInstanceType (typeExpr)->isCGFloatType ();
5535+ return getInstanceType (typeExpr)->isCGFloat ();
55235536 }
55245537 }
55255538 return false ;
@@ -5548,7 +5561,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
55485561 return false ;
55495562 })) {
55505563 conversionsOrFixes.push_back (
5551- desugar1->isCGFloatType ()
5564+ desugar1->isCGFloat ()
55525565 ? ConversionRestrictionKind::CGFloatToDouble
55535566 : ConversionRestrictionKind::DoubleToCGFloat);
55545567 }
0 commit comments