Skip to content

Commit 9e3a058

Browse files
committed
[CSSimplify] Detect and fix implicit Double <-> CGFloat conversion via optional chaining
Passing Double? to CGFloat? and vice versa is not supported but there was one case which solver still allowed to get through - optional chains, which is not fixed.
1 parent 9acd1d9 commit 9e3a058

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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,

0 commit comments

Comments
 (0)