@@ -610,6 +610,24 @@ module LocalFlow {
610
610
or
611
611
exists ( Switch sw | sw .getACase ( ) = cfe and sw .getExpr ( ) = e1 and scope = sw )
612
612
)
613
+ or
614
+ isSuccessor = true and
615
+ scope =
616
+ any ( IsExpr ie |
617
+ e1 = ie .getExpr ( ) and
618
+ e2 = ie .getPattern ( )
619
+ )
620
+ or
621
+ isSuccessor = true and
622
+ scope =
623
+ any ( Switch e |
624
+ e1 = e .getExpr ( ) and
625
+ e2 = e .getACase ( ) .getPattern ( )
626
+ )
627
+ or
628
+ isSuccessor = false and
629
+ e2 = e1 .( RecursivePatternExpr ) .getPropertyPatterns ( ) and
630
+ scope = e1
613
631
)
614
632
}
615
633
@@ -907,27 +925,28 @@ private predicate fieldOrPropertyStore(Expr e, ContentSet c, Expr src, Expr q, b
907
925
)
908
926
}
909
927
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
914
- prop .getDeclaringType ( ) = ta .getType ( ) and
915
- prop .getName ( ) = e .( LabeledPatternExpr ) .getLabel ( ) and
916
- c .isProperty ( prop )
928
+ /**
929
+ * TODO: Should we consider to override getType on pattern expressions?
930
+ */
931
+ private Type getPatternType ( PatternExpr pe ) {
932
+ result = pe .( RecursivePatternExpr ) .getTypeAccess ( ) .getType ( )
933
+ or
934
+ not pe instanceof LabeledPatternExpr and
935
+ result = getPatternType ( pe .getParent ( ) )
936
+ or
937
+ exists ( Property p |
938
+ result = p .getType ( ) and
939
+ p .getDeclaringType ( ) = getPatternType ( pe .getParent ( ) ) and
940
+ p .getName ( ) = pe .( LabeledPatternExpr ) .getLabel ( )
917
941
)
918
942
}
919
943
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 )
944
+ private predicate patternPropertyRead ( PropertyPatternExpr pe , ContentSet c , LabeledPatternExpr e ) {
945
+ exists ( Property prop |
946
+ e = pe .getPattern ( _) and
947
+ prop .getDeclaringType ( ) = getPatternType ( pe ) and
948
+ prop .getName ( ) = e .getLabel ( ) and
949
+ c .isProperty ( prop )
931
950
)
932
951
}
933
952
@@ -2454,7 +2473,7 @@ private class ReadStepConfiguration extends ControlFlowReachabilityConfiguration
2454
2473
isSuccessor = false
2455
2474
or
2456
2475
exactScope = false and
2457
- isSuccessor = true and
2476
+ isSuccessor = false and
2458
2477
patternPropertyRead ( e1 , _, e2 ) and
2459
2478
scope = e1
2460
2479
}
0 commit comments