File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -508,8 +508,8 @@ matchCallArguments(SmallVectorImpl<AnyFunctionType::Param> &args,
508
508
// If there's no suitable last parameter to accept the trailing closure,
509
509
// notify the listener and bail if we need to.
510
510
if (!unlabeledParamIdx) {
511
+ // Try to use a specialized diagnostic for an extra closure.
511
512
bool isExtraClosure = false ;
512
-
513
513
if (prevParamIdx == 0 ) {
514
514
isExtraClosure = true ;
515
515
} else if (unlabeledArgIdx > 0 ) {
@@ -534,7 +534,16 @@ matchCallArguments(SmallVectorImpl<AnyFunctionType::Param> &args,
534
534
return true ;
535
535
}
536
536
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) {
538
547
// Claim the parameter/argument pair.
539
548
claim (params[*unlabeledParamIdx].getLabel (), unlabeledArgIdx,
540
549
/* ignoreNameClash=*/ true );
You can’t perform that action at this time.
0 commit comments