Skip to content

Commit dc8b6f9

Browse files
Kotlin: unify enum library-test query across suites
The `enum` library test used two different queries in test-kotlin1 and test-kotlin2, so their `.expected` files were not comparable (78 divergent lines that reflected the query difference, not an extractor difference): * test-kotlin1: `from Method m, RefType t where t = m.getDeclaringType() and t.getName() = ["Enum", "Enum<?>", "Enum<E>", "EnumUserKt"] select t.getQualifiedName(), t.getName(), m.getName()` * test-kotlin2: `from Method m where m.getDeclaringType().getName().matches("Enum%") select m.getName()` The K1 query is the more precise of the two: it pins the declaring types by exact name and reports the qualified name alongside the method, whereas the K2 `matches("Enum%")` form also pulls in unrelated `java.util.EnumSet` members as noise. We adopt the K1 query in both suites (a pure test-input synchronisation, no extractor change). After unification the two suites' output is identical except for a single row: test-kotlin2 additionally reports `kotlin.Enum | Enum | finalize`. That is a compiler-builtin difference (the Kotlin `kotlin.Enum` built-in class exposes `finalize` under the 2.4.0/K2 frontend but not under the 2.3.20/K1 frontend); it is a compiler-version artifact of the built-in class member set, not something the extractor synthesises, so it is tracked separately rather than papered over here. All 3333 tests pass in both suites; test-kotlin1 is unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d91b389 commit dc8b6f9

2 files changed

Lines changed: 49 additions & 38 deletions

File tree

java/ql/test-kotlin2/library-tests/enum/test.expected

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,48 @@
11
#select
2-
| addAll |
3-
| addRange |
4-
| allOf |
5-
| asIterator |
6-
| clone |
7-
| compareTo |
8-
| complement |
9-
| complementOf |
10-
| copyOf |
11-
| describeConstable |
12-
| equals |
13-
| finalize |
14-
| forEach |
15-
| getDeclaringClass |
16-
| getFirst |
17-
| getLast |
18-
| hasMoreElements |
19-
| hashCode |
20-
| name |
21-
| nextElement |
22-
| noneOf |
23-
| of |
24-
| ordinal |
25-
| parallelStream |
26-
| range |
27-
| resolveConstantDesc |
28-
| reversed |
29-
| spliterator |
30-
| stream |
31-
| toArray |
32-
| toString |
33-
| typeCheck |
34-
| usesEnum |
35-
| valueOf |
36-
| writeReplace |
2+
| EnumUserKt | EnumUserKt | usesEnum |
3+
| java.lang.Enum | Enum | clone |
4+
| java.lang.Enum | Enum | compareTo |
5+
| java.lang.Enum | Enum | describeConstable |
6+
| java.lang.Enum | Enum | equals |
7+
| java.lang.Enum | Enum | finalize |
8+
| java.lang.Enum | Enum | getDeclaringClass |
9+
| java.lang.Enum | Enum | hashCode |
10+
| java.lang.Enum | Enum | name |
11+
| java.lang.Enum | Enum | ordinal |
12+
| java.lang.Enum | Enum | toString |
13+
| java.lang.Enum | Enum | valueOf |
14+
| java.lang.Enum<?> | Enum<?> | clone |
15+
| java.lang.Enum<?> | Enum<?> | compareTo |
16+
| java.lang.Enum<?> | Enum<?> | describeConstable |
17+
| java.lang.Enum<?> | Enum<?> | equals |
18+
| java.lang.Enum<?> | Enum<?> | finalize |
19+
| java.lang.Enum<?> | Enum<?> | getDeclaringClass |
20+
| java.lang.Enum<?> | Enum<?> | hashCode |
21+
| java.lang.Enum<?> | Enum<?> | name |
22+
| java.lang.Enum<?> | Enum<?> | ordinal |
23+
| java.lang.Enum<?> | Enum<?> | toString |
24+
| java.lang.Enum<?> | Enum<?> | valueOf |
25+
| java.lang.Enum<E> | Enum<E> | clone |
26+
| java.lang.Enum<E> | Enum<E> | compareTo |
27+
| java.lang.Enum<E> | Enum<E> | describeConstable |
28+
| java.lang.Enum<E> | Enum<E> | equals |
29+
| java.lang.Enum<E> | Enum<E> | finalize |
30+
| java.lang.Enum<E> | Enum<E> | getDeclaringClass |
31+
| java.lang.Enum<E> | Enum<E> | hashCode |
32+
| java.lang.Enum<E> | Enum<E> | name |
33+
| java.lang.Enum<E> | Enum<E> | ordinal |
34+
| java.lang.Enum<E> | Enum<E> | toString |
35+
| java.lang.Enum<E> | Enum<E> | valueOf |
36+
| kotlin.Enum | Enum | clone |
37+
| kotlin.Enum | Enum | compareTo |
38+
| kotlin.Enum | Enum | describeConstable |
39+
| kotlin.Enum | Enum | equals |
40+
| kotlin.Enum | Enum | finalize |
41+
| kotlin.Enum | Enum | getDeclaringClass |
42+
| kotlin.Enum | Enum | hashCode |
43+
| kotlin.Enum | Enum | name |
44+
| kotlin.Enum | Enum | ordinal |
45+
| kotlin.Enum | Enum | toString |
3746
enumConstants
3847
| enumUser.kt:3:16:3:17 | A |
3948
| enumUser.kt:3:19:3:20 | B |
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import java
22

3-
from Method m
4-
where m.getDeclaringType().getName().matches("Enum%")
5-
select m.getName()
3+
from Method m, RefType t
4+
where
5+
t = m.getDeclaringType() and
6+
t.getName() = ["Enum", "Enum<?>", "Enum<E>", "EnumUserKt"]
7+
select t.getQualifiedName(), t.getName(), m.getName()
68

79
query predicate enumConstants(EnumConstant ec) { ec.fromSource() }

0 commit comments

Comments
 (0)