Skip to content

Commit 8ca05d8

Browse files
committed
Exclude annotations from consistency check due to intentionally missing children
1 parent 70ebb41 commit 8ca05d8

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

java/ql/consistency-queries/children.ql

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ predicate gapInChildren(Element e, int i) {
4141
// -1 can be skipped (type arguments from -2 down, no qualifier at -1,
4242
// then arguments from 0).
4343
// Can we also skip arguments, e.g. due to defaults for parameters?
44-
not (e instanceof MethodAccess and e.getFile().isKotlinSourceFile())
44+
not (e instanceof MethodAccess and e.getFile().isKotlinSourceFile()) and
45+
// Kotlin-extracted annotations can have missing children where a default
46+
// value should be, because kotlinc doesn't load annotation defaults and we
47+
// want to leave a space for another extractor to fill in the default if it
48+
// is able.
49+
not e instanceof Annotation
4550
}
4651

4752
predicate lateFirstChild(Element e, int i) {
@@ -59,7 +64,12 @@ predicate lateFirstChild(Element e, int i) {
5964
not (e instanceof LocalVariableDeclStmt and i = 1 and not exists(nthChildOf(e, 2))) and
6065
// For statements may or may not declare a new variable (child 0), or
6166
// have a condition (child 1).
62-
not (e instanceof ForStmt and i = [1, 2])
67+
not (e instanceof ForStmt and i = [1, 2]) and
68+
// Kotlin-extracted annotations can have missing children where a default
69+
// value should be, because kotlinc doesn't load annotation defaults and we
70+
// want to leave a space for another extractor to fill in the default if it
71+
// is able.
72+
not e instanceof Annotation
6373
}
6474

6575
from Element e, int i, string problem

0 commit comments

Comments
 (0)