Skip to content

Commit 5e0961b

Browse files
committed
Account for new possible child index gap
1 parent 9fa2f19 commit 5e0961b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

java/ql/consistency-queries/children.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ predicate gapInChildren(Element e, int i) {
4949
not e instanceof Annotation and
5050
// Pattern case statements legitimately have a TypeAccess (-2) and a pattern (0) but not a rule (-1)
5151
not (i = -1 and e instanceof PatternCase and not e.(PatternCase).isRule()) and
52+
// Pattern case statements can have a gap at -3 when they have more than one pattern but no guard.
53+
not (i = -3 and count(e.(PatternCase).getAPattern()) > 1 and not exists(e.(PatternCase).getGuard())) and
5254
// Instanceof with a record pattern is not expected to have a type access in position 1
5355
not (i = 1 and e.(InstanceOfExpr).getPattern() instanceof RecordPatternExpr) and
5456
// RecordPatternExpr extracts type-accesses only for its LocalVariableDeclExpr children

0 commit comments

Comments
 (0)