@@ -282,22 +282,19 @@ static bool matchCallArgumentsImpl(
282
282
// requiring further checking at the end.
283
283
bool potentiallyOutOfOrder = false ;
284
284
285
- // Local function that claims the argument at \c argNumber , returning the
285
+ // Local function that claims the argument at \c argIdx , returning the
286
286
// index of the claimed argument. This is primarily a helper for
287
287
// \c claimNextNamed.
288
- auto claim = [&](Identifier expectedName, unsigned argNumber ,
288
+ auto claim = [&](Identifier expectedName, unsigned argIdx ,
289
289
bool ignoreNameClash = false ) -> unsigned {
290
290
// Make sure we can claim this argument.
291
- assert (argNumber != numArgs && " Must have a valid index to claim" );
292
- assert (!claimedArgs[argNumber ] && " Argument already claimed" );
291
+ assert (argIdx != numArgs && " Must have a valid index to claim" );
292
+ assert (!claimedArgs[argIdx ] && " Argument already claimed" );
293
293
294
- auto argLabel = args[argNumber].getLabel ();
295
294
if (!actualArgNames.empty ()) {
296
295
// We're recording argument names; record this one.
297
- actualArgNames[argNumber] = expectedName;
298
- } else if (argLabel != expectedName && !ignoreNameClash &&
299
- !(argLabel.str ().startswith (" $" ) &&
300
- argLabel.str ().drop_front () == expectedName.str ())) {
296
+ actualArgNames[argIdx] = expectedName;
297
+ } else if (!ignoreNameClash && !args[argIdx].matchParameterLabel (expectedName)) {
301
298
// We have an argument name mismatch. Start recording argument names.
302
299
actualArgNames.resize (numArgs);
303
300
@@ -313,12 +310,12 @@ static bool matchCallArgumentsImpl(
313
310
}
314
311
315
312
// Record this argument name.
316
- actualArgNames[argNumber ] = expectedName;
313
+ actualArgNames[argIdx ] = expectedName;
317
314
}
318
315
319
- claimedArgs[argNumber ] = true ;
316
+ claimedArgs[argIdx ] = true ;
320
317
++numClaimedArgs;
321
- return argNumber ;
318
+ return argIdx ;
322
319
};
323
320
324
321
// Local function that skips over any claimed arguments.
@@ -343,11 +340,8 @@ static bool matchCallArgumentsImpl(
343
340
// Go hunting for an unclaimed argument whose name does match.
344
341
Optional<unsigned > claimedWithSameName;
345
342
for (unsigned i = nextArgIdx; i != numArgs; ++i) {
346
- auto argLabel = args[i].getLabel ();
347
343
348
- if (argLabel != paramLabel &&
349
- !(argLabel.str ().startswith (" $" ) &&
350
- argLabel.str ().drop_front () == paramLabel.str ())) {
344
+ if (!args[i].matchParameterLabel (paramLabel)) {
351
345
// If this is an attempt to claim additional unlabeled arguments
352
346
// for variadic parameter, we have to stop at first labeled argument.
353
347
if (forVariadic)
@@ -379,7 +373,7 @@ static bool matchCallArgumentsImpl(
379
373
// func foo(_ a: Int, _ b: Int = 0, c: Int = 0, _ d: Int) {}
380
374
// foo(1, c: 2, 3) // -> `3` will be claimed as '_ b:'.
381
375
// ```
382
- if (argLabel .empty ())
376
+ if (args[i]. getLabel () .empty ())
383
377
continue ;
384
378
385
379
potentiallyOutOfOrder = true ;
0 commit comments