Skip to content

Commit 116b664

Browse files
committed
[ConstraintSystem] Use locator from result of cast rather than source.
Be consistent with CoerceExpr and for the constraint we create use the locator from the result of the expression rather than the locator from the source of the expression.
1 parent 12e7caf commit 116b664

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/Sema/CSGen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,7 +2512,7 @@ namespace {
25122512
expr->getCastTypeLoc().setType(toType, /*validated=*/true);
25132513

25142514
auto fromType = CS.getType(fromExpr);
2515-
auto locator = CS.getConstraintLocator(fromExpr);
2515+
auto locator = CS.getConstraintLocator(expr);
25162516

25172517
// The source type can be checked-cast to the destination type.
25182518
CS.addConstraint(ConstraintKind::CheckedCast, fromType, toType, locator);
@@ -2560,7 +2560,7 @@ namespace {
25602560
expr->getCastTypeLoc().setType(toType, /*validated=*/true);
25612561

25622562
auto fromType = CS.getType(fromExpr);
2563-
auto locator = CS.getConstraintLocator(fromExpr);
2563+
auto locator = CS.getConstraintLocator(expr);
25642564
CS.addConstraint(ConstraintKind::CheckedCast, fromType, toType, locator);
25652565
return OptionalType::get(toType);
25662566
}

0 commit comments

Comments
 (0)