Skip to content

Commit f2fded6

Browse files
committed
Accept jvmstatic-annotation changes
These occur because the Companion field is odd, being extracted from source but not having an associated FieldDeclaration, leading to PrintAst enumerating the node differently depending on whether it has a source-file location or not but in either case choosing not to show it.
1 parent 5e023bf commit f2fded6

File tree

2 files changed

+20
-58
lines changed

2 files changed

+20
-58
lines changed

java/ql/test/kotlin/library-tests/jvmstatic-annotation/PrintAst.expected

Lines changed: 20 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ test.kt:
141141
# 65| 0: [MethodAccess] getPropWithStaticGetter(...)
142142
# 65| -1: [TypeAccess] NonCompanion
143143
# 9| 2: [Class] HasCompanion
144-
# 9| 2: [Constructor] HasCompanion
144+
# 9| 1: [Constructor] HasCompanion
145145
# 9| 5: [BlockStmt] { ... }
146146
# 9| 0: [SuperConstructorInvocationStmt] super(...)
147147
# 9| 1: [BlockStmt] { ... }
148-
# 11| 3: [Class] Companion
148+
# 11| 2: [Class] Companion
149149
# 11| 1: [Constructor] Companion
150150
# 11| 5: [BlockStmt] { ... }
151151
# 11| 0: [SuperConstructorInvocationStmt] super(...)
@@ -157,23 +157,19 @@ test.kt:
157157
# 17| 0: [KtInitializerAssignExpr] ...=...
158158
# 17| 0: [VarAccess] nonStaticProp
159159
# 13| 2: [Method] staticMethod
160-
#-----| 1: (Annotations)
161160
# 13| 3: [TypeAccess] String
162161
#-----| 4: (Parameters)
163162
# 13| 0: [Parameter] s
164-
#-----| -1: (Annotations)
165163
# 13| 0: [TypeAccess] String
166164
# 13| 5: [BlockStmt] { ... }
167165
# 13| 0: [ReturnStmt] return ...
168166
# 13| 0: [MethodAccess] nonStaticMethod(...)
169167
# 13| -1: [ThisAccess] this
170168
# 13| 0: [VarAccess] s
171169
# 14| 3: [Method] nonStaticMethod
172-
#-----| 1: (Annotations)
173170
# 14| 3: [TypeAccess] String
174171
#-----| 4: (Parameters)
175172
# 14| 0: [Parameter] s
176-
#-----| -1: (Annotations)
177173
# 14| 0: [TypeAccess] String
178174
# 14| 5: [BlockStmt] { ... }
179175
# 14| 0: [ReturnStmt] return ...
@@ -184,7 +180,6 @@ test.kt:
184180
# 16| -1: [TypeAccess] String
185181
# 16| 0: [StringLiteral] "a"
186182
# 16| 5: [Method] getStaticProp
187-
#-----| 1: (Annotations)
188183
# 16| 3: [TypeAccess] String
189184
# 16| 5: [BlockStmt] { ... }
190185
# 16| 0: [ReturnStmt] return ...
@@ -194,7 +189,6 @@ test.kt:
194189
# 16| 3: [TypeAccess] Unit
195190
#-----| 4: (Parameters)
196191
# 16| 0: [Parameter] <set-?>
197-
#-----| -1: (Annotations)
198192
# 16| 0: [TypeAccess] String
199193
# 16| 5: [BlockStmt] { ... }
200194
# 16| 0: [ExprStmt] <Expr>;
@@ -206,7 +200,6 @@ test.kt:
206200
# 17| -1: [TypeAccess] String
207201
# 17| 0: [StringLiteral] "b"
208202
# 17| 8: [Method] getNonStaticProp
209-
#-----| 1: (Annotations)
210203
# 17| 3: [TypeAccess] String
211204
# 17| 5: [BlockStmt] { ... }
212205
# 17| 0: [ReturnStmt] return ...
@@ -216,7 +209,6 @@ test.kt:
216209
# 17| 3: [TypeAccess] Unit
217210
#-----| 4: (Parameters)
218211
# 17| 0: [Parameter] <set-?>
219-
#-----| -1: (Annotations)
220212
# 17| 0: [TypeAccess] String
221213
# 17| 5: [BlockStmt] { ... }
222214
# 17| 0: [ExprStmt] <Expr>;
@@ -225,7 +217,6 @@ test.kt:
225217
# 17| -1: [ThisAccess] this
226218
# 17| 1: [VarAccess] <set-?>
227219
# 20| 10: [Method] getPropWithStaticGetter
228-
#-----| 1: (Annotations)
229220
# 20| 3: [TypeAccess] String
230221
# 20| 5: [BlockStmt] { ... }
231222
# 20| 0: [ReturnStmt] return ...
@@ -235,79 +226,68 @@ test.kt:
235226
# 21| 3: [TypeAccess] Unit
236227
#-----| 4: (Parameters)
237228
# 21| 0: [Parameter] s
238-
#-----| -1: (Annotations)
239229
# 21| 0: [TypeAccess] String
240230
# 21| 5: [BlockStmt] { ... }
241231
# 21| 0: [ExprStmt] <Expr>;
242232
# 21| 0: [MethodAccess] setPropWithStaticSetter(...)
243233
# 21| -1: [ThisAccess] this
244234
# 21| 0: [VarAccess] s
245235
# 24| 12: [Method] getPropWithStaticSetter
246-
#-----| 1: (Annotations)
247236
# 24| 3: [TypeAccess] String
248237
# 24| 5: [BlockStmt] { ... }
249238
# 24| 0: [ReturnStmt] return ...
250239
# 24| 0: [MethodAccess] getPropWithStaticGetter(...)
251240
# 24| -1: [ThisAccess] this
252241
# 25| 13: [Method] setPropWithStaticSetter
253-
#-----| 1: (Annotations)
254242
# 25| 3: [TypeAccess] Unit
255243
#-----| 4: (Parameters)
256244
# 25| 0: [Parameter] s
257-
#-----| -1: (Annotations)
258245
# 25| 0: [TypeAccess] String
259246
# 25| 5: [BlockStmt] { ... }
260247
# 25| 0: [ExprStmt] <Expr>;
261248
# 25| 0: [MethodAccess] setPropWithStaticGetter(...)
262249
# 25| -1: [ThisAccess] this
263250
# 25| 0: [VarAccess] s
264-
# 13| 4: [Method] staticMethod
265-
#-----| 1: (Annotations)
251+
# 13| 3: [Method] staticMethod
266252
# 13| 3: [TypeAccess] String
267253
#-----| 4: (Parameters)
268254
# 13| 0: [Parameter] s
269-
#-----| -1: (Annotations)
270255
# 13| 0: [TypeAccess] String
271256
# 13| 5: [BlockStmt] { ... }
272257
# 13| 0: [ReturnStmt] return ...
273258
# 13| 0: [MethodAccess] staticMethod(...)
274259
# 13| -1: [VarAccess] HasCompanion.Companion
275260
# 13| -1: [TypeAccess] HasCompanion
276261
# 13| 0: [VarAccess] s
277-
# 16| 5: [Method] getStaticProp
278-
#-----| 1: (Annotations)
262+
# 16| 4: [Method] getStaticProp
279263
# 16| 3: [TypeAccess] String
280264
# 16| 5: [BlockStmt] { ... }
281265
# 16| 0: [ReturnStmt] return ...
282266
# 16| 0: [MethodAccess] getStaticProp(...)
283267
# 16| -1: [VarAccess] HasCompanion.Companion
284268
# 16| -1: [TypeAccess] HasCompanion
285-
# 16| 6: [Method] setStaticProp
269+
# 16| 5: [Method] setStaticProp
286270
# 16| 3: [TypeAccess] Unit
287271
#-----| 4: (Parameters)
288272
# 16| 0: [Parameter] <set-?>
289-
#-----| -1: (Annotations)
290273
# 16| 0: [TypeAccess] String
291274
# 16| 5: [BlockStmt] { ... }
292275
# 16| 0: [ReturnStmt] return ...
293276
# 16| 0: [MethodAccess] setStaticProp(...)
294277
# 16| -1: [VarAccess] HasCompanion.Companion
295278
# 16| -1: [TypeAccess] HasCompanion
296279
# 16| 0: [VarAccess] <set-?>
297-
# 20| 7: [Method] getPropWithStaticGetter
298-
#-----| 1: (Annotations)
280+
# 20| 6: [Method] getPropWithStaticGetter
299281
# 20| 3: [TypeAccess] String
300282
# 20| 5: [BlockStmt] { ... }
301283
# 20| 0: [ReturnStmt] return ...
302284
# 20| 0: [MethodAccess] getPropWithStaticGetter(...)
303285
# 20| -1: [VarAccess] HasCompanion.Companion
304286
# 20| -1: [TypeAccess] HasCompanion
305-
# 25| 8: [Method] setPropWithStaticSetter
306-
#-----| 1: (Annotations)
287+
# 25| 7: [Method] setPropWithStaticSetter
307288
# 25| 3: [TypeAccess] Unit
308289
#-----| 4: (Parameters)
309290
# 25| 0: [Parameter] s
310-
#-----| -1: (Annotations)
311291
# 25| 0: [TypeAccess] String
312292
# 25| 5: [BlockStmt] { ... }
313293
# 25| 0: [ReturnStmt] return ...
@@ -316,7 +296,7 @@ test.kt:
316296
# 25| -1: [TypeAccess] HasCompanion
317297
# 25| 0: [VarAccess] s
318298
# 31| 3: [Class] NonCompanion
319-
# 31| 2: [Constructor] NonCompanion
299+
# 31| 1: [Constructor] NonCompanion
320300
# 31| 5: [BlockStmt] { ... }
321301
# 31| 0: [SuperConstructorInvocationStmt] super(...)
322302
# 31| 1: [BlockStmt] { ... }
@@ -326,47 +306,41 @@ test.kt:
326306
# 37| 1: [ExprStmt] <Expr>;
327307
# 37| 0: [KtInitializerAssignExpr] ...=...
328308
# 37| 0: [VarAccess] nonStaticProp
329-
# 33| 3: [Method] staticMethod
330-
#-----| 1: (Annotations)
309+
# 33| 2: [Method] staticMethod
331310
# 33| 3: [TypeAccess] String
332311
#-----| 4: (Parameters)
333312
# 33| 0: [Parameter] s
334-
#-----| -1: (Annotations)
335313
# 33| 0: [TypeAccess] String
336314
# 33| 5: [BlockStmt] { ... }
337315
# 33| 0: [ReturnStmt] return ...
338316
# 33| 0: [MethodAccess] nonStaticMethod(...)
339317
# 33| -1: [VarAccess] NonCompanion.INSTANCE
340318
# 33| -1: [TypeAccess] NonCompanion
341319
# 33| 0: [VarAccess] s
342-
# 34| 4: [Method] nonStaticMethod
343-
#-----| 1: (Annotations)
320+
# 34| 3: [Method] nonStaticMethod
344321
# 34| 3: [TypeAccess] String
345322
#-----| 4: (Parameters)
346323
# 34| 0: [Parameter] s
347-
#-----| -1: (Annotations)
348324
# 34| 0: [TypeAccess] String
349325
# 34| 5: [BlockStmt] { ... }
350326
# 34| 0: [ReturnStmt] return ...
351327
# 34| 0: [MethodAccess] staticMethod(...)
352328
# 34| -1: [TypeAccess] NonCompanion
353329
# 34| 0: [VarAccess] s
354-
# 36| 5: [FieldDeclaration] String staticProp;
330+
# 36| 4: [FieldDeclaration] String staticProp;
355331
# 36| -1: [TypeAccess] String
356332
# 36| 0: [StringLiteral] "a"
357-
# 36| 6: [Method] getStaticProp
358-
#-----| 1: (Annotations)
333+
# 36| 5: [Method] getStaticProp
359334
# 36| 3: [TypeAccess] String
360335
# 36| 5: [BlockStmt] { ... }
361336
# 36| 0: [ReturnStmt] return ...
362337
# 36| 0: [VarAccess] NonCompanion.INSTANCE.staticProp
363338
# 36| -1: [VarAccess] NonCompanion.INSTANCE
364339
# 36| -1: [TypeAccess] NonCompanion
365-
# 36| 7: [Method] setStaticProp
340+
# 36| 6: [Method] setStaticProp
366341
# 36| 3: [TypeAccess] Unit
367342
#-----| 4: (Parameters)
368343
# 36| 0: [Parameter] <set-?>
369-
#-----| -1: (Annotations)
370344
# 36| 0: [TypeAccess] String
371345
# 36| 5: [BlockStmt] { ... }
372346
# 36| 0: [ExprStmt] <Expr>;
@@ -375,60 +349,53 @@ test.kt:
375349
# 36| -1: [VarAccess] NonCompanion.INSTANCE
376350
# 36| -1: [TypeAccess] NonCompanion
377351
# 36| 1: [VarAccess] <set-?>
378-
# 37| 8: [FieldDeclaration] String nonStaticProp;
352+
# 37| 7: [FieldDeclaration] String nonStaticProp;
379353
# 37| -1: [TypeAccess] String
380354
# 37| 0: [StringLiteral] "b"
381-
# 37| 9: [Method] getNonStaticProp
382-
#-----| 1: (Annotations)
355+
# 37| 8: [Method] getNonStaticProp
383356
# 37| 3: [TypeAccess] String
384357
# 37| 5: [BlockStmt] { ... }
385358
# 37| 0: [ReturnStmt] return ...
386359
# 37| 0: [VarAccess] this.nonStaticProp
387360
# 37| -1: [ThisAccess] this
388-
# 37| 10: [Method] setNonStaticProp
361+
# 37| 9: [Method] setNonStaticProp
389362
# 37| 3: [TypeAccess] Unit
390363
#-----| 4: (Parameters)
391364
# 37| 0: [Parameter] <set-?>
392-
#-----| -1: (Annotations)
393365
# 37| 0: [TypeAccess] String
394366
# 37| 5: [BlockStmt] { ... }
395367
# 37| 0: [ExprStmt] <Expr>;
396368
# 37| 0: [AssignExpr] ...=...
397369
# 37| 0: [VarAccess] this.nonStaticProp
398370
# 37| -1: [ThisAccess] this
399371
# 37| 1: [VarAccess] <set-?>
400-
# 40| 11: [Method] getPropWithStaticGetter
401-
#-----| 1: (Annotations)
372+
# 40| 10: [Method] getPropWithStaticGetter
402373
# 40| 3: [TypeAccess] String
403374
# 40| 5: [BlockStmt] { ... }
404375
# 40| 0: [ReturnStmt] return ...
405376
# 40| 0: [MethodAccess] getPropWithStaticSetter(...)
406377
# 40| -1: [VarAccess] NonCompanion.INSTANCE
407378
# 40| -1: [TypeAccess] NonCompanion
408-
# 41| 12: [Method] setPropWithStaticGetter
379+
# 41| 11: [Method] setPropWithStaticGetter
409380
# 41| 3: [TypeAccess] Unit
410381
#-----| 4: (Parameters)
411382
# 41| 0: [Parameter] s
412-
#-----| -1: (Annotations)
413383
# 41| 0: [TypeAccess] String
414384
# 41| 5: [BlockStmt] { ... }
415385
# 41| 0: [ExprStmt] <Expr>;
416386
# 41| 0: [MethodAccess] setPropWithStaticSetter(...)
417387
# 41| -1: [TypeAccess] NonCompanion
418388
# 41| 0: [VarAccess] s
419-
# 44| 13: [Method] getPropWithStaticSetter
420-
#-----| 1: (Annotations)
389+
# 44| 12: [Method] getPropWithStaticSetter
421390
# 44| 3: [TypeAccess] String
422391
# 44| 5: [BlockStmt] { ... }
423392
# 44| 0: [ReturnStmt] return ...
424393
# 44| 0: [MethodAccess] getPropWithStaticGetter(...)
425394
# 44| -1: [TypeAccess] NonCompanion
426-
# 45| 14: [Method] setPropWithStaticSetter
427-
#-----| 1: (Annotations)
395+
# 45| 13: [Method] setPropWithStaticSetter
428396
# 45| 3: [TypeAccess] Unit
429397
#-----| 4: (Parameters)
430398
# 45| 0: [Parameter] s
431-
#-----| -1: (Annotations)
432399
# 45| 0: [TypeAccess] String
433400
# 45| 5: [BlockStmt] { ... }
434401
# 45| 0: [ExprStmt] <Expr>;

java/ql/test/kotlin/library-tests/jvmstatic-annotation/test.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,3 @@ fun externalUser() {
6565
NonCompanion.propWithStaticSetter = NonCompanion.propWithStaticGetter
6666

6767
}
68-
69-
// Diagnostic Matches: Completion failure for type: kotlin.jvm.JvmStatic
70-
// Diagnostic Matches: Completion failure for type: org.jetbrains.annotations.NotNull
71-
// Diagnostic Matches: Unknown location for kotlin.jvm.JvmStatic
72-
// Diagnostic Matches: Unknown location for org.jetbrains.annotations.NotNull

0 commit comments

Comments
 (0)