Skip to content

Commit cc82ae0

Browse files
committed
Fix RawRepresentable fix-its for single unlabeled arguments
They were being put outside the call parentheses instead of inside. We even had tests for this; I just got them wrong. https://bugs.swift.org/browse/SR-8150
1 parent 84f17e1 commit cc82ae0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4575,9 +4575,10 @@ static bool diagnoseRawRepresentableMismatch(CalleeCandidateInfo &CCI,
45754575
if (!isRawRepresentableMismatch(argType, paramType, kind, CS))
45764576
continue;
45774577

4578-
auto *expr = argExpr;
4578+
const Expr *expr = argExpr;
45794579
if (tupleArgs)
45804580
expr = tupleArgs->getElement(i);
4581+
expr = expr->getValueProvidingExpr();
45814582

45824583
auto diag =
45834584
CS.TC.diagnose(expr->getLoc(), diag::cannot_convert_argument_value,

test/Sema/enum_raw_representable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ rdar32431165_1(.baz)
120120
// expected-error@-1 {{reference to member 'baz' cannot be resolved without a contextual type}}
121121

122122
rdar32431165_1("")
123-
// expected-error@-1 {{cannot convert value of type 'String' to expected argument type 'E_32431165'}} {{15-15=E_32431165(rawValue: }} {{19-19=)}}
123+
// expected-error@-1 {{cannot convert value of type 'String' to expected argument type 'E_32431165'}} {{16-16=E_32431165(rawValue: }} {{18-18=)}}
124124
rdar32431165_1(42, "")
125125
// expected-error@-1 {{cannot convert value of type 'String' to expected argument type 'E_32431165'}} {{20-20=E_32431165(rawValue: }} {{22-22=)}}
126126

@@ -129,7 +129,7 @@ func rdar32431165_2(_: Int) {}
129129
func rdar32431165_2(_: Int, _: String) {}
130130

131131
rdar32431165_2(E_32431165.bar)
132-
// expected-error@-1 {{cannot convert value of type 'E_32431165' to expected argument type 'String'}} {{15-15=}} {{31-31=.rawValue}}
132+
// expected-error@-1 {{cannot convert value of type 'E_32431165' to expected argument type 'String'}} {{16-16=}} {{30-30=.rawValue}}
133133
rdar32431165_2(42, E_32431165.bar)
134134
// expected-error@-1 {{cannot convert value of type 'E_32431165' to expected argument type 'String'}} {{20-20=}} {{34-34=.rawValue}}
135135

0 commit comments

Comments
 (0)