Skip to content

Commit 015d838

Browse files
committed
Claim trailing closure arguments like we used to in error cases.
1 parent 67838cd commit 015d838

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,8 @@ matchCallArguments(SmallVectorImpl<AnyFunctionType::Param> &args,
508508
// If there's no suitable last parameter to accept the trailing closure,
509509
// notify the listener and bail if we need to.
510510
if (!unlabeledParamIdx) {
511+
// Try to use a specialized diagnostic for an extra closure.
511512
bool isExtraClosure = false;
512-
513513
if (prevParamIdx == 0) {
514514
isExtraClosure = true;
515515
} else if (unlabeledArgIdx > 0) {
@@ -534,7 +534,16 @@ matchCallArguments(SmallVectorImpl<AnyFunctionType::Param> &args,
534534
return true;
535535
}
536536

537-
} else {
537+
if (isExtraClosure) {
538+
// Claim the unlabeled trailing closure without an associated
539+
// parameter to suppress further complaints about it.
540+
claim(Identifier(), unlabeledArgIdx, /*ignoreNameClash=*/true);
541+
} else {
542+
unlabeledParamIdx = prevParamIdx - 1;
543+
}
544+
}
545+
546+
if (unlabeledParamIdx) {
538547
// Claim the parameter/argument pair.
539548
claim(params[*unlabeledParamIdx].getLabel(), unlabeledArgIdx,
540549
/*ignoreNameClash=*/true);

0 commit comments

Comments
 (0)