Skip to content

Commit 837bef6

Browse files
committed
Add java.lang.Enum ordinal and name accessors to special-cased JVM names
Kotlin represents these as read-only properties with unusual getter names.
1 parent d151bf6 commit 837bef6

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ open class KotlinUsesExtractor(
8585
makeDescription(StandardNames.FqNames.map, "<get-entries>") to "entrySet",
8686
makeDescription(FqName("java.util.Map"), "<get-entries>") to "entrySet",
8787
makeDescription(StandardNames.FqNames.mutableList, "removeAt") to "remove",
88-
makeDescription(FqName("java.util.List"), "removeAt") to "remove"
88+
makeDescription(FqName("java.util.List"), "removeAt") to "remove",
89+
makeDescription(StandardNames.FqNames._enum.toSafe(), "<get-ordinal>") to "ordinal",
90+
makeDescription(FqName("java.lang.Enum"), "<get-ordinal>") to "ordinal",
91+
makeDescription(StandardNames.FqNames._enum.toSafe(), "<get-name>") to "name",
92+
makeDescription(FqName("java.lang.Enum"), "<get-name>") to "name",
8993
)
9094

9195
private val specialFunctionShortNames = specialFunctions.keys.map { it.functionName }.toSet()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fun usesEnum(e: Enum<*>) = e.ordinal.toString() + e.name
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
| addAll |
2+
| addRange |
3+
| allOf |
4+
| asIterator |
5+
| clone |
6+
| compareTo |
7+
| complement |
8+
| complementOf |
9+
| copyOf |
10+
| describeConstable |
11+
| equals |
12+
| finalize |
13+
| getDeclaringClass |
14+
| hasMoreElements |
15+
| hashCode |
16+
| name |
17+
| nextElement |
18+
| noneOf |
19+
| of |
20+
| ordinal |
21+
| range |
22+
| resolveConstantDesc |
23+
| toString |
24+
| typeCheck |
25+
| usesEnum |
26+
| valueOf |
27+
| writeReplace |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import java
2+
3+
from Method m
4+
where m.getDeclaringType().getName().matches("Enum%")
5+
select m.getName()

0 commit comments

Comments
 (0)