Skip to content

Commit 63315cc

Browse files
[Diagnostics] Adjust ExtraneousArgumentsFailure note diagnostic
1 parent 9abda4a commit 63315cc

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,10 +1403,13 @@ WARNING(unlabeled_trailing_closure_deprecated,Deprecation,
14031403
NOTE(decl_multiple_defaulted_closure_parameters,none,
14041404
"%0 contains defaulted closure parameters %1 and %2",
14051405
(DeclName, Identifier, Identifier))
1406+
NOTE(candidate_with_extraneous_args_closure,none,
1407+
"candidate %0 requires %1 argument%s1, "
1408+
"but %2 %select{were|was}3 used in closure body",
1409+
(Type, unsigned, unsigned, bool))
14061410
NOTE(candidate_with_extraneous_args,none,
1407-
"candidate %0 requires %1 argument%s1, "
1408-
"but %2 %select{were|was}3 %select{provided|used in closure body}4",
1409-
(Type, unsigned, unsigned, bool, bool))
1411+
"candidate %0 has %1 parameter%s1, but context %2 has %3",
1412+
(Type, unsigned, Type, unsigned))
14101413

14111414
ERROR(no_accessible_initializers,none,
14121415
"%0 cannot be constructed because it has no accessible initializers",

lib/Sema/CSDiagnostics.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5735,9 +5735,15 @@ bool ExtraneousArgumentsFailure::diagnoseAsNote() {
57355735

57365736
auto *decl = overload->choice.getDecl();
57375737
auto numArgs = getTotalNumArguments();
5738-
emitDiagnosticAt(decl, diag::candidate_with_extraneous_args, ContextualType,
5739-
ContextualType->getNumParams(), numArgs, (numArgs == 1),
5740-
isExpr<ClosureExpr>(getAnchor()));
5738+
if (isExpr<ClosureExpr>(getAnchor())) {
5739+
emitDiagnosticAt(decl, diag::candidate_with_extraneous_args_closure,
5740+
ContextualType, ContextualType->getNumParams(), numArgs,
5741+
(numArgs == 1));
5742+
} else {
5743+
emitDiagnosticAt(decl, diag::candidate_with_extraneous_args,
5744+
decl->getInterfaceType(), numArgs, ContextualType,
5745+
ContextualType->getNumParams());
5746+
}
57415747
return true;
57425748
}
57435749

0 commit comments

Comments
 (0)