Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 64aa111

Browse files
authored
Merge pull request #1342 from aschackmull/java/field-annotation-cu
Java: Check compilation unit of the same element in both disjuncts.
2 parents 8fe2bcc + 3e5bbd9 commit 64aa111

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

java/ql/src/semmle/code/java/Annotation.qll

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@ class Annotation extends @annotation, Expr {
2525

2626
/** Gets the element being annotated. */
2727
Element getAnnotatedElement() {
28-
this.getParent().(Field).getDeclaration().getAField() = result and
29-
this.getCompilationUnit().fromSource()
30-
or
31-
not result.(Field).getCompilationUnit().fromSource() and
32-
this.getParent() = result
28+
exists(Element e | e = this.getParent() |
29+
if e.(Field).getCompilationUnit().fromSource()
30+
then
31+
exists(FieldDeclaration decl |
32+
decl.getField(0) = e and
33+
result = decl.getAField()
34+
)
35+
else result = e
36+
)
3337
}
3438

3539
/** Gets the annotation type declaration for this annotation. */

0 commit comments

Comments
 (0)