@@ -136,13 +136,15 @@ private module Cached {
136
136
newtype TParameterPosition =
137
137
TPositionalParameterPosition ( int i ) { i = any ( Parameter p ) .getPosition ( ) } or
138
138
TThisParameterPosition ( ) or
139
- TImplicitCapturedParameterPosition ( LocalScopeVariable v ) { capturedWithFlowIn ( v ) }
139
+ TImplicitCapturedParameterPosition ( LocalScopeVariable v ) { capturedWithFlowIn ( v ) } or
140
+ TDelegateSelfParameterPosition ( )
140
141
141
142
cached
142
143
newtype TArgumentPosition =
143
144
TPositionalArgumentPosition ( int i ) { i = any ( Parameter p ) .getPosition ( ) } or
144
145
TQualifierArgumentPosition ( ) or
145
- TImplicitCapturedArgumentPosition ( LocalScopeVariable v ) { capturedWithFlowIn ( v ) }
146
+ TImplicitCapturedArgumentPosition ( LocalScopeVariable v ) { capturedWithFlowIn ( v ) } or
147
+ TDelegateSelfArgumentPosition ( )
146
148
}
147
149
148
150
import Cached
@@ -480,6 +482,14 @@ class ParameterPosition extends TParameterPosition {
480
482
this = TImplicitCapturedParameterPosition ( v )
481
483
}
482
484
485
+ /**
486
+ * Holds if this position represents a reference to a delegate itself.
487
+ *
488
+ * Used for tracking flow through captured variables and for improving
489
+ * delegate dispatch.
490
+ */
491
+ predicate isDelegateSelf ( ) { this = TDelegateSelfParameterPosition ( ) }
492
+
483
493
/** Gets a textual representation of this position. */
484
494
string toString ( ) {
485
495
result = "position " + this .getPosition ( )
@@ -489,6 +499,9 @@ class ParameterPosition extends TParameterPosition {
489
499
exists ( LocalScopeVariable v |
490
500
this .isImplicitCapturedParameterPosition ( v ) and result = "captured " + v
491
501
)
502
+ or
503
+ this .isDelegateSelf ( ) and
504
+ result = "delegate self"
492
505
}
493
506
}
494
507
@@ -505,6 +518,14 @@ class ArgumentPosition extends TArgumentPosition {
505
518
this = TImplicitCapturedArgumentPosition ( v )
506
519
}
507
520
521
+ /**
522
+ * Holds if this position represents a reference to a delegate itself.
523
+ *
524
+ * Used for tracking flow through captured variables and for improving
525
+ * delegate dispatch.
526
+ */
527
+ predicate isDelegateSelf ( ) { this = TDelegateSelfArgumentPosition ( ) }
528
+
508
529
/** Gets a textual representation of this position. */
509
530
string toString ( ) {
510
531
result = "position " + this .getPosition ( )
@@ -514,6 +535,9 @@ class ArgumentPosition extends TArgumentPosition {
514
535
exists ( LocalScopeVariable v |
515
536
this .isImplicitCapturedArgumentPosition ( v ) and result = "captured " + v
516
537
)
538
+ or
539
+ this .isDelegateSelf ( ) and
540
+ result = "delegate self"
517
541
}
518
542
}
519
543
@@ -527,6 +551,8 @@ predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) {
527
551
ppos .isImplicitCapturedParameterPosition ( v ) and
528
552
apos .isImplicitCapturedArgumentPosition ( v )
529
553
)
554
+ or
555
+ ppos .isDelegateSelf ( ) and apos .isDelegateSelf ( )
530
556
}
531
557
532
558
/**
0 commit comments