Skip to content

Commit 01d7d51

Browse files
authored
Merge pull request #60137 from xedin/rdar-97261826
[CSApply] Use fully qualified locator while coercing member chain result
2 parents e497c55 + 53ce55a commit 01d7d51

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/Sema/CSApply.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3466,7 +3466,10 @@ namespace {
34663466
// type.
34673467
auto *subExpr = expr->getSubExpr();
34683468
auto type = simplifyType(cs.getType(expr));
3469-
subExpr = coerceToType(subExpr, type, cs.getConstraintLocator(subExpr));
3469+
subExpr = coerceToType(
3470+
subExpr, type,
3471+
cs.getConstraintLocator(
3472+
expr, ConstraintLocator::UnresolvedMemberChainResult));
34703473
cs.setType(subExpr, type);
34713474
return subExpr;
34723475
}

test/Constraints/implicit_double_cgfloat_conversion.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,21 @@ func assignments_with_and_without_optionals() {
262262
copy.prop = (true ? cgf : (false ? v : cgf))
263263
}
264264
}
265+
266+
extension CGFloat {
267+
static let `default` = 42.0
268+
}
269+
270+
// rdar://97261826 - crash during constraint application with leading-dot syntax
271+
func assignment_with_leading_dot_syntax() {
272+
class Container {
273+
var prop: CGFloat = 0
274+
}
275+
276+
struct Test {
277+
let test: Void = {
278+
let c = Container()
279+
c.prop = .default // Ok (Double -> CGFloat)
280+
}()
281+
}
282+
}

0 commit comments

Comments
 (0)