Skip to content

Commit 8e16aa4

Browse files
committed
[Diagnostics] Extend argument-to-parameter mismatch note to cover inout parameters
1 parent 773ac24 commit 8e16aa4

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ ERROR(cannot_convert_argument_value,none,
381381
(Type,Type))
382382

383383
NOTE(candidate_has_invalid_argument_at_position,none,
384-
"candidate expects value of type %0 for parameter #%1",
385-
(Type, unsigned))
384+
"candidate expects %select{|in-out }2value of type %0 for parameter #%1",
385+
(Type, unsigned, bool))
386386

387387
ERROR(cannot_convert_array_to_variadic,none,
388388
"cannot pass array of type %0 as variadic arguments of type %1",

lib/Sema/CSDiagnostics.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5084,9 +5084,11 @@ bool ArgumentMismatchFailure::diagnoseAsError() {
50845084
}
50855085

50865086
bool ArgumentMismatchFailure::diagnoseAsNote() {
5087+
auto *locator = getLocator();
50875088
if (auto *callee = getCallee()) {
50885089
emitDiagnostic(callee, diag::candidate_has_invalid_argument_at_position,
5089-
getToType(), getParamPosition());
5090+
getToType(), getParamPosition(),
5091+
locator->isLastElement<LocatorPathElt::LValueConversion>());
50905092
return true;
50915093
}
50925094

test/expr/postfix/dot/init_ref_delegation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,8 @@ struct MultipleMemberAccesses {
549549

550550
func sr10670() {
551551
struct S {
552-
init(_ x: inout String) {} // expected-note {{candidate expects value of type 'String' for parameter #1}}
553-
init(_ x: inout [Int]) {} // expected-note {{candidate expects value of type '[Int]' for parameter #1}}
552+
init(_ x: inout String) {} // expected-note {{candidate expects in-out value of type 'String' for parameter #1}}
553+
init(_ x: inout [Int]) {} // expected-note {{candidate expects in-out value of type '[Int]' for parameter #1}}
554554
}
555555
var a = 0
556556
S.init(&a) // expected-error {{no exact matches in call to initializer}}

0 commit comments

Comments
 (0)