Skip to content

Commit 24472c9

Browse files
committed
[ConstraintSystem] Allow Double<->CGFloat conversions only if they are AST representable
Allow Double <-> CGFloat conversion if the associated locator is simplifiable down to a AST node (e.g. expression) this limits applications of such conversions to e.g. argument-to-parameter, contextual conversions and forbids conversions in generic arguments, function result, collection elements etc.
1 parent dc6cf03 commit 24472c9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5087,6 +5087,12 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
50875087
nominal1->getDecl() != nominal2->getDecl() &&
50885088
((nominal1->isCGFloatType() || nominal2->isCGFloatType()) &&
50895089
(nominal1->isDoubleType() || nominal2->isDoubleType()))) {
5090+
// Support implicit Double<->CGFloat conversions only for
5091+
// something which could be directly represented in the AST
5092+
// e.g. argument-to-parameter, contextual conversions etc.
5093+
if (!locator.trySimplifyToExpr())
5094+
return getTypeMatchFailure(locator);
5095+
50905096
SmallVector<LocatorPathElt, 4> path;
50915097
auto anchor = locator.getLocatorParts(path);
50925098

0 commit comments

Comments
 (0)