diff --git a/java/ql/src/semmle/code/java/Annotation.qll b/java/ql/src/semmle/code/java/Annotation.qll index 64a597e1e55..b05635826d9 100755 --- a/java/ql/src/semmle/code/java/Annotation.qll +++ b/java/ql/src/semmle/code/java/Annotation.qll @@ -25,11 +25,11 @@ class Annotation extends @annotation, Expr { /** Gets the element being annotated. */ Element getAnnotatedElement() { - this.getParent().(Field).getDeclaration().getAField() = result and - this.getCompilationUnit().fromSource() - or - not result.(Field).getCompilationUnit().fromSource() and - this.getParent() = result + exists(Element e | e = this.getParent() | + if e.(Field).getCompilationUnit().fromSource() + then result = e.(Field).getDeclaration().getAField() + else result = e + ) } /** Gets the annotation type declaration for this annotation. */