@@ -640,9 +640,10 @@ module LocalFlow {
640640 )
641641 or
642642 // Needed for read steps for pattern matching involving properties.
643+ // TODO: Can be written in a more nice way.
643644 scope = def .getExpr ( ) and
644645 e .( VariablePatternExpr ) .getVariableDeclExpr ( ) =
645- def .( AssignableDefinitions:: PatternDefinition ) .getExpr ( ) and
646+ def .( AssignableDefinitions:: PatternDefinition ) .getDeclaration ( ) and
646647 exactScope = false and
647648 isSuccessor = false and
648649 not def .( AssignableDefinitions:: PatternDefinition ) .isTopLevel ( )
@@ -906,18 +907,30 @@ private predicate fieldOrPropertyStore(Expr e, ContentSet c, Expr src, Expr q, b
906907 )
907908}
908909
909- private predicate patternPropertyRead ( Expr e1 , ContentSet c , VariablePatternExpr e2 ) {
910- exists ( IsExpr ie , RecursivePatternExpr p , TypeAccess ta , Property prop |
911- e1 = ie .getExpr ( ) and
912- p = ie .getPattern ( ) and
913- ta = p .getTypeAccess ( ) and
914- e2 = p .getPropertyPatterns ( ) .getPattern ( _) and
910+ private predicate patternPropertyRead0 ( RecursivePatternExpr rpe , ContentSet c , VariablePatternExpr e ) {
911+ exists ( TypeAccess ta , Property prop |
912+ ta = rpe .getTypeAccess ( ) and
913+ e = rpe .getPropertyPatterns ( ) .getPattern ( _) and
915914 prop .getDeclaringType ( ) = ta .getType ( ) and
916- prop .getName ( ) = e2 .( LabeledPatternExpr ) .getLabel ( ) and
915+ prop .getName ( ) = e .( LabeledPatternExpr ) .getLabel ( ) and
917916 c .isProperty ( prop )
918917 )
919918}
920919
920+ private predicate patternPropertyRead ( Expr e1 , ContentSet c , VariablePatternExpr e2 ) {
921+ exists ( IsExpr ie , RecursivePatternExpr rpe |
922+ e1 = ie .getExpr ( ) and
923+ rpe = ie .getPattern ( ) and
924+ patternPropertyRead0 ( rpe , c , e2 )
925+ )
926+ or
927+ exists ( Switch sw , RecursivePatternExpr rpe |
928+ e1 = sw .getExpr ( ) and
929+ rpe = sw .getACase ( ) .getPattern ( ) and
930+ patternPropertyRead0 ( rpe , c , e2 )
931+ )
932+ }
933+
921934/**
922935 * Holds if `e2` is an expression that reads field or property `c` from
923936 * expression `e1`.
0 commit comments