@@ -563,7 +563,11 @@ private module Cached {
563
563
THashSplatArgumentPosition ( ) or
564
564
TSynthHashSplatArgumentPosition ( ) or
565
565
TSplatArgumentPosition ( int pos ) { exists ( Call c | c .getArgument ( pos ) instanceof SplatExpr ) } or
566
- TSynthSplatArgumentPosition ( Boolean hasActualSplat ) or
566
+ TSynthSplatArgumentPosition ( int actualSplatPos ) {
567
+ actualSplatPos = - 1 // represents no actual splat
568
+ or
569
+ exists ( Callable c | c .getParameter ( actualSplatPos ) instanceof SplatParameter )
570
+ } or
567
571
TAnyArgumentPosition ( ) or
568
572
TAnyKeywordArgumentPosition ( )
569
573
@@ -594,7 +598,11 @@ private module Cached {
594
598
or
595
599
exists ( Parameter p | p .getPosition ( ) = pos and p instanceof SplatParameter )
596
600
} or
597
- TSynthSplatParameterPosition ( Boolean hasActualSplat ) or
601
+ TSynthSplatParameterPosition ( int actualSplatPos ) {
602
+ actualSplatPos = - 1 // represents no actual splat
603
+ or
604
+ exists ( Call c | c .getArgument ( actualSplatPos ) instanceof SplatExpr )
605
+ } or
598
606
TAnyParameterPosition ( ) or
599
607
TAnyKeywordParameterPosition ( )
600
608
}
@@ -1386,12 +1394,11 @@ class ParameterPosition extends TParameterPosition {
1386
1394
/**
1387
1395
* Holds if this position represents a synthetic splat parameter.
1388
1396
*
1389
- * `hasActualSplat` indicates whether the method that the parameter belongs
1390
- * to also has an actual splat parameter.
1397
+ * `actualSplatPos` indicates the position of the (unique) actual splat
1398
+ * parameter belonging to the same method, with `-1` representing no actual
1399
+ * splat parameter.
1391
1400
*/
1392
- predicate isSynthSplat ( boolean hasActualSplat ) {
1393
- this = TSynthSplatParameterPosition ( hasActualSplat )
1394
- }
1401
+ predicate isSynthSplat ( int actualSplatPos ) { this = TSynthSplatParameterPosition ( actualSplatPos ) }
1395
1402
1396
1403
/**
1397
1404
* Holds if this position represents any parameter, except `self` parameters. This
@@ -1426,10 +1433,10 @@ class ParameterPosition extends TParameterPosition {
1426
1433
or
1427
1434
exists ( int pos | this .isSplat ( pos ) and result = "* (position " + pos + ")" )
1428
1435
or
1429
- exists ( boolean hasActualSplat , string suffix |
1430
- this .isSynthSplat ( hasActualSplat ) and
1436
+ exists ( int actualSplatPos , string suffix |
1437
+ this .isSynthSplat ( actualSplatPos ) and
1431
1438
result = "synthetic *" + suffix and
1432
- if hasActualSplat = true then suffix = " (with actual) " else suffix = ""
1439
+ if actualSplatPos = - 1 then suffix = "" else suffix = " (actual at " + actualSplatPos + ") "
1433
1440
)
1434
1441
}
1435
1442
}
@@ -1472,12 +1479,11 @@ class ArgumentPosition extends TArgumentPosition {
1472
1479
/**
1473
1480
* Holds if this position represents a synthetic splat argument.
1474
1481
*
1475
- * `hasActualSplat` indicates whether the call that the argument belongs
1476
- * to also has an actual splat argument.
1482
+ * `actualSplatPos` indicates the position of the (unique) actual splat
1483
+ * argument belonging to the same call, with `-1` representing no actual
1484
+ * splat argument.
1477
1485
*/
1478
- predicate isSynthSplat ( boolean hasActualSplat ) {
1479
- this = TSynthSplatArgumentPosition ( hasActualSplat )
1480
- }
1486
+ predicate isSynthSplat ( int actualSplatPos ) { this = TSynthSplatArgumentPosition ( actualSplatPos ) }
1481
1487
1482
1488
/** Gets a textual representation of this position. */
1483
1489
string toString ( ) {
@@ -1501,10 +1507,10 @@ class ArgumentPosition extends TArgumentPosition {
1501
1507
or
1502
1508
exists ( int pos | this .isSplat ( pos ) and result = "* (position " + pos + ")" )
1503
1509
or
1504
- exists ( boolean hasActualSplat , string suffix |
1505
- this .isSynthSplat ( hasActualSplat ) and
1510
+ exists ( int actualSplatPos , string suffix |
1511
+ this .isSynthSplat ( actualSplatPos ) and
1506
1512
result = "synthetic *" + suffix and
1507
- if hasActualSplat = true then suffix = " (with actual) " else suffix = ""
1513
+ if actualSplatPos = - 1 then suffix = "" else suffix = " (actual at " + actualSplatPos + ") "
1508
1514
)
1509
1515
}
1510
1516
}
@@ -1538,35 +1544,30 @@ predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) {
1538
1544
or
1539
1545
exists ( string name | ppos .isKeyword ( name ) and apos .isKeyword ( name ) )
1540
1546
or
1541
- ppos .isHashSplat ( ) and
1542
- ( apos .isHashSplat ( ) or apos .isSynthHashSplat ( ) )
1543
- or
1544
- // no case for `apos.isSynthHashSplat() and ppos.isSynthHashSplat()`, since
1545
- // direct keyword matching is possible
1546
- ppos .isSynthHashSplat ( ) and
1547
- apos .isHashSplat ( )
1547
+ ( ppos .isHashSplat ( ) or ppos .isSynthHashSplat ( ) ) and
1548
+ ( apos .isHashSplat ( ) or apos .isSynthHashSplat ( ) ) and
1549
+ // prevent synthetic hash-splat parameters from matching synthetic hash-splat
1550
+ // arguments when direct keyword matching is possible
1551
+ not ( ppos .isSynthHashSplat ( ) and apos .isSynthHashSplat ( ) )
1548
1552
or
1549
- exists ( int pos , boolean hasActualSplatParam , boolean hasActualSplatArg |
1553
+ exists ( int pos |
1550
1554
(
1551
- ppos .isSplat ( pos ) and
1552
- hasActualSplatParam = true // allow matching with synthetic splat argument
1555
+ ppos .isSplat ( pos )
1553
1556
or
1554
- ppos .isSynthSplat ( hasActualSplatParam ) and
1555
- pos = 0 and
1556
- // prevent synthetic splat parameters from matching synthetic splat arguments
1557
- // when direct positional matching is possible
1558
- (
1559
- hasActualSplatParam = true
1560
- or
1561
- hasActualSplatArg = true
1562
- )
1557
+ ppos .isSynthSplat ( _) and
1558
+ pos = 0
1563
1559
) and
1564
1560
(
1565
- apos .isSplat ( pos ) and
1566
- hasActualSplatArg = true // allow matching with synthetic splat parameter
1561
+ apos .isSplat ( pos )
1567
1562
or
1568
- apos .isSynthSplat ( hasActualSplatArg ) and pos = 0
1563
+ apos .isSynthSplat ( _ ) and pos = 0
1569
1564
)
1565
+ ) and
1566
+ // prevent synthetic splat parameters from matching synthetic splat arguments
1567
+ // when direct positional matching is possible
1568
+ not exists ( int actualSplatPos |
1569
+ ppos .isSynthSplat ( actualSplatPos ) and
1570
+ apos .isSynthSplat ( actualSplatPos )
1570
1571
)
1571
1572
or
1572
1573
ppos .isAny ( ) and argumentPositionIsNotSelf ( apos )
0 commit comments