Skip to content

Commit 7a7c08b

Browse files
committed
Tolerate generic annotations
This causes them to render properly in PrintAst output due to `getAnnotationElement` working as expected, and will hide the fact that they are represented by raw types in bytecode.
1 parent f6888c7 commit 7a7c08b

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

java/ql/integration-tests/all-platforms/kotlin/annotation-id-consistency/PrintAst.expected

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,14 @@ test.kt:
184184
# 0| 0: [TypeAccess] int
185185
# 0| 3: [VarAccess] DayOfWeek.MONDAY
186186
# 0| -1: [TypeAccess] DayOfWeek
187-
# 18| 3: [Annotation] GenericAnnotation<>
187+
# 18| 3: [Annotation] GenericAnnotation
188+
# 0| 1: [TypeLiteral] String.class
189+
# 0| 0: [TypeAccess] String
190+
# 0| 2: [ArrayInit] {...}
191+
# 0| 1: [TypeLiteral] String.class
192+
# 0| 0: [TypeAccess] String
193+
# 0| 2: [TypeLiteral] String.class
194+
# 0| 0: [TypeAccess] String
188195
# 24| 4: [Annotation] AnnWithDefaults
189196
# 0| 1: [IntegerLiteral] 1
190197
# 0| 2: [StringLiteral] "hello"
@@ -242,7 +249,14 @@ test.kt:
242249
# 0| 0: [TypeAccess] int
243250
# 0| 3: [VarAccess] DayOfWeek.MONDAY
244251
# 0| -1: [TypeAccess] DayOfWeek
245-
# 28| 3: [Annotation] GenericAnnotation<>
252+
# 28| 3: [Annotation] GenericAnnotation
253+
# 0| 1: [TypeLiteral] String.class
254+
# 0| 0: [TypeAccess] String
255+
# 0| 2: [ArrayInit] {...}
256+
# 0| 1: [TypeLiteral] String.class
257+
# 0| 0: [TypeAccess] String
258+
# 0| 2: [TypeLiteral] String.class
259+
# 0| 0: [TypeAccess] String
246260
# 34| 4: [Annotation] AnnWithDefaults
247261
# 0| 1: [IntegerLiteral] 1
248262
# 0| 2: [StringLiteral] "hello"
@@ -285,17 +299,3 @@ test.kt:
285299
# 46| 5: [BlockStmt] { ... }
286300
# 46| 0: [SuperConstructorInvocationStmt] super(...)
287301
# 47| 1: [BlockStmt] { ... }
288-
# 0| [TypeLiteral] String.class
289-
# 0| 0: [TypeAccess] String
290-
# 0| [ArrayInit] {...}
291-
# 0| 1: [TypeLiteral] String.class
292-
# 0| 0: [TypeAccess] String
293-
# 0| 2: [TypeLiteral] String.class
294-
# 0| 0: [TypeAccess] String
295-
# 0| [TypeLiteral] String.class
296-
# 0| 0: [TypeAccess] String
297-
# 0| [ArrayInit] {...}
298-
# 0| 1: [TypeLiteral] String.class
299-
# 0| 0: [TypeAccess] String
300-
# 0| 2: [TypeLiteral] String.class
301-
# 0| 0: [TypeAccess] String

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Annotation extends @annotation, Expr {
3737
}
3838

3939
/** Gets the annotation type declaration for this annotation. */
40-
override AnnotationType getType() { result = Expr.super.getType() }
40+
override AnnotationType getType() { result = Expr.super.getType().(AnnotationType).getSourceDeclaration() }
4141

4242
/** Gets the annotation element with the specified `name`. */
4343
AnnotationElement getAnnotationElement(string name) {

0 commit comments

Comments
 (0)