Skip to content

Commit a695d85

Browse files
authored
Merge pull request swiftlang#19644 from harlanhaskins/literally
2 parents 7b03ea5 + 8e4379e commit a695d85

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lib/Sema/CSApply.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3573,12 +3573,10 @@ namespace {
35733573

35743574
auto &tc = cs.getTypeChecker();
35753575

3576-
// Since this is literal initialization, we don't
3577-
// really need to keep wrapping coercion around.
3576+
// If this is a literal that got converted into constructor call
3577+
// lets put proper source information in place.
35783578
if (expr->isLiteralInit()) {
35793579
auto *literalInit = expr->getSubExpr();
3580-
// If literal got converted into constructor call
3581-
// lets put proper source information in place.
35823580
if (auto *call = dyn_cast<CallExpr>(literalInit)) {
35833581
call->getFn()->forEachChildExpr([&](Expr *subExpr) -> Expr * {
35843582
auto *TE = dyn_cast<TypeExpr>(subExpr);
@@ -3600,7 +3598,10 @@ namespace {
36003598
}
36013599

36023600
literalInit->setImplicit(false);
3603-
return literalInit;
3601+
3602+
// Keep the coercion around, because it contains the source range
3603+
// for the original constructor call.
3604+
return expr;
36043605
}
36053606

36063607
// Turn the subexpression into an rvalue.

test/Constraints/diagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ func SR_6272_a() {
953953
case bar
954954
}
955955

956-
// expected-error@+2 {{binary operator '*' cannot be applied to operands of type 'Int' and 'Float'}} {{35-35=Int(}} {{42-42=)}}
956+
// expected-error@+2 {{binary operator '*' cannot be applied to operands of type 'Int' and 'Float'}} {{35-35=Int(}} {{43-43=)}}
957957
// expected-note@+1 {{expected an argument list of type '(Int, Int)'}}
958958
let _: Int = Foo.bar.rawValue * Float(0)
959959

0 commit comments

Comments
 (0)