@@ -13,11 +13,11 @@ private import semmle.code.csharp.frameworks.system.Collections
1313private import semmle.code.csharp.frameworks.system.collections.Generic
1414
1515private predicate summarizedCallable ( DataFlowCallable c ) {
16- c instanceof FlowSummary :: SummarizedCallable
16+ exists ( c . asSummarizedCallable ( ) )
1717 or
1818 FlowSummaryImpl:: Private:: summaryReturnNode ( _, TJumpReturnKind ( c , _) )
1919 or
20- c = interpretElement ( _, _, _, _, _, _)
20+ c . asCallable ( ) = interpretElement ( _, _, _, _, _, _)
2121}
2222
2323/**
@@ -29,7 +29,7 @@ private predicate summarizedCallable(DataFlowCallable c) {
2929 */
3030DotNet:: Callable getCallableForDataFlow ( DotNet:: Callable c ) {
3131 exists ( DotNet:: Callable unboundDecl | unboundDecl = c .getUnboundDeclaration ( ) |
32- summarizedCallable ( unboundDecl ) and
32+ summarizedCallable ( TDotNetCallable ( unboundDecl ) ) and
3333 result = unboundDecl
3434 or
3535 result .hasBody ( ) and
@@ -84,11 +84,11 @@ newtype TReturnKind =
8484 TJumpReturnKind ( DataFlowCallable target , ReturnKind rk ) {
8585 rk instanceof NormalReturnKind and
8686 (
87- target instanceof Constructor or
88- not target .getReturnType ( ) instanceof VoidType
87+ target . asCallable ( ) instanceof Constructor or
88+ not target .asCallable ( ) . getReturnType ( ) instanceof VoidType
8989 )
9090 or
91- exists ( target .getParameter ( rk .( OutRefReturnKind ) .getPosition ( ) ) )
91+ exists ( target .asCallable ( ) . getParameter ( rk .( OutRefReturnKind ) .getPosition ( ) ) )
9292 }
9393
9494private module Cached {
@@ -108,7 +108,7 @@ private module Cached {
108108 // No need to include calls that are compiled from source
109109 not call .getImplementation ( ) .getMethod ( ) .compiledFromSource ( )
110110 } or
111- TSummaryCall ( FlowSummary :: SummarizedCallable c , Node receiver ) {
111+ TSummaryCall ( FlowSummaryImpl :: Public :: SummarizedCallable c , Node receiver ) {
112112 FlowSummaryImpl:: Private:: summaryCallbackRange ( c , receiver )
113113 }
114114
@@ -145,7 +145,7 @@ private module DispatchImpl {
145145 * the enclosing callable `c` (including the implicit `this` parameter).
146146 */
147147 predicate mayBenefitFromCallContext ( NonDelegateDataFlowCall call , Callable c ) {
148- c = call .getEnclosingCallable ( ) and
148+ c = call .getEnclosingCallable ( ) . asCallable ( ) and
149149 call .getDispatchCall ( ) .mayBenefitFromCallContext ( )
150150 }
151151
@@ -154,7 +154,7 @@ private module DispatchImpl {
154154 * restricted to those `call`s for which a context might make a difference.
155155 */
156156 DataFlowCallable viableImplInCallContext ( NonDelegateDataFlowCall call , DataFlowCall ctx ) {
157- result =
157+ result . asCallable ( ) =
158158 call .getDispatchCall ( )
159159 .getADynamicTargetInCallContext ( ctx .( NonDelegateDataFlowCall ) .getDispatchCall ( ) )
160160 .getUnboundDeclaration ( )
@@ -256,7 +256,7 @@ newtype TDataFlowCallable =
256256
257257class DataFlowCallable extends TDataFlowCallable {
258258 /** Get the underlying source code callable, if any. */
259- Callable asCallable ( ) { this = TDotNetCallable ( result ) }
259+ DotNet :: Callable asCallable ( ) { this = TDotNetCallable ( result ) }
260260
261261 /** Get the underlying summarized callable, if any. */
262262 FlowSummary:: SummarizedCallable asSummarizedCallable ( ) { this = TSummarizedCallable ( result ) }
@@ -327,18 +327,20 @@ class NonDelegateDataFlowCall extends DataFlowCall, TNonDelegateCall {
327327 DispatchCall getDispatchCall ( ) { result = dc }
328328
329329 override DataFlowCallable getARuntimeTarget ( ) {
330- result = getCallableForDataFlow ( dc .getADynamicTarget ( ) )
330+ result . asCallable ( ) = getCallableForDataFlow ( dc .getADynamicTarget ( ) )
331331 or
332- result = dc .getAStaticTarget ( ) .getUnboundDeclaration ( ) and
332+ result . asCallable ( ) = dc .getAStaticTarget ( ) .getUnboundDeclaration ( ) and
333333 summarizedCallable ( result ) and
334- not result instanceof RuntimeCallable
334+ not result . asCallable ( ) instanceof RuntimeCallable
335335 }
336336
337337 override ControlFlow:: Nodes:: ElementNode getControlFlowNode ( ) { result = cfn }
338338
339339 override DataFlow:: ExprNode getNode ( ) { result .getControlFlowNode ( ) = cfn }
340340
341- override DataFlowCallable getEnclosingCallable ( ) { result = cfn .getEnclosingCallable ( ) }
341+ override DataFlowCallable getEnclosingCallable ( ) {
342+ result .asCallable ( ) = cfn .getEnclosingCallable ( )
343+ }
342344
343345 override string toString ( ) { result = cfn .toString ( ) }
344346
@@ -366,7 +368,9 @@ class ExplicitDelegateLikeDataFlowCall extends DelegateDataFlowCall, TExplicitDe
366368
367369 override DataFlow:: ExprNode getNode ( ) { result .getControlFlowNode ( ) = cfn }
368370
369- override DataFlowCallable getEnclosingCallable ( ) { result = cfn .getEnclosingCallable ( ) }
371+ override DataFlowCallable getEnclosingCallable ( ) {
372+ result .asCallable ( ) = cfn .getEnclosingCallable ( )
373+ }
370374
371375 override string toString ( ) { result = cfn .toString ( ) }
372376
@@ -384,13 +388,15 @@ class TransitiveCapturedDataFlowCall extends DataFlowCall, TTransitiveCapturedCa
384388
385389 TransitiveCapturedDataFlowCall ( ) { this = TTransitiveCapturedCall ( cfn , target ) }
386390
387- override DataFlowCallable getARuntimeTarget ( ) { result = target }
391+ override DataFlowCallable getARuntimeTarget ( ) { result . asCallable ( ) = target }
388392
389393 override ControlFlow:: Nodes:: ElementNode getControlFlowNode ( ) { result = cfn }
390394
391395 override DataFlow:: ExprNode getNode ( ) { none ( ) }
392396
393- override DataFlowCallable getEnclosingCallable ( ) { result = cfn .getEnclosingCallable ( ) }
397+ override DataFlowCallable getEnclosingCallable ( ) {
398+ result .asCallable ( ) = cfn .getEnclosingCallable ( )
399+ }
394400
395401 override string toString ( ) { result = "[transitive] " + cfn .toString ( ) }
396402
@@ -405,14 +411,16 @@ class CilDataFlowCall extends DataFlowCall, TCilCall {
405411
406412 override DataFlowCallable getARuntimeTarget ( ) {
407413 // There is no dispatch library for CIL, so do not consider overrides for now
408- result = getCallableForDataFlow ( call .getTarget ( ) )
414+ result . asCallable ( ) = getCallableForDataFlow ( call .getTarget ( ) )
409415 }
410416
411417 override ControlFlow:: Nodes:: ElementNode getControlFlowNode ( ) { none ( ) }
412418
413419 override DataFlow:: ExprNode getNode ( ) { result .getExpr ( ) = call }
414420
415- override DataFlowCallable getEnclosingCallable ( ) { result = call .getEnclosingCallable ( ) }
421+ override DataFlowCallable getEnclosingCallable ( ) {
422+ result .asCallable ( ) = call .getEnclosingCallable ( )
423+ }
416424
417425 override string toString ( ) { result = call .toString ( ) }
418426
@@ -427,7 +435,7 @@ class CilDataFlowCall extends DataFlowCall, TCilCall {
427435 * the method `Select`.
428436 */
429437class SummaryCall extends DelegateDataFlowCall , TSummaryCall {
430- private FlowSummary :: SummarizedCallable c ;
438+ private FlowSummaryImpl :: Public :: SummarizedCallable c ;
431439 private Node receiver ;
432440
433441 SummaryCall ( ) { this = TSummaryCall ( c , receiver ) }
0 commit comments