@@ -118,7 +118,7 @@ private module LambdaFlow {
118118 boolean toJump , DataFlowCallOption lastCall
119119 ) {
120120 revLambdaFlow0 ( lambdaCall , kind , node , t , toReturn , toJump , lastCall ) and
121- if node instanceof CastNode or node instanceof ArgumentNode or node instanceof ReturnNode
121+ if castNode ( node ) or node instanceof ArgumentNode or node instanceof ReturnNode
122122 then compatibleTypes ( t , getNodeDataFlowType ( node ) )
123123 else any ( )
124124 }
@@ -290,6 +290,20 @@ private module Cached {
290290 )
291291 }
292292
293+ cached
294+ predicate castNode ( Node n ) { n instanceof CastNode }
295+
296+ cached
297+ predicate castingNode ( Node n ) {
298+ castNode ( n ) or
299+ n instanceof ParameterNode or
300+ n instanceof OutNodeExt or
301+ // For reads, `x.f`, we want to check that the tracked type after the read (which
302+ // is obtained by popping the head of the access path stack) is compatible with
303+ // the type of `x.f`.
304+ read ( _, _, n )
305+ }
306+
293307 /**
294308 * Gets a viable target for the lambda call `call`.
295309 *
@@ -818,15 +832,7 @@ private module Cached {
818832 * A `Node` at which a cast can occur such that the type should be checked.
819833 */
820834class CastingNode extends Node {
821- CastingNode ( ) {
822- this instanceof ParameterNode or
823- this instanceof CastNode or
824- this instanceof OutNodeExt or
825- // For reads, `x.f`, we want to check that the tracked type after the read (which
826- // is obtained by popping the head of the access path stack) is compatible with
827- // the type of `x.f`.
828- read ( _, _, this )
829- }
835+ CastingNode ( ) { castingNode ( this ) }
830836}
831837
832838private predicate readStepWithTypes (
0 commit comments