[JVM] Lower .entries calls on Kotlin enums

Leveraging the same mechanism with $EntriesMapping as Java enums.
Old (compiled with LV/AV < 1.8) enums are detected by looking for
static special <get-entries> method that cannot be introduced on
Kotlin enums otherwise

#KT-53236
This commit is contained in:
Vsevolod Tolstopyatov
2022-07-22 14:33:28 +02:00
committed by Space
parent a12a31ce68
commit e3bff290bd
20 changed files with 268 additions and 18 deletions
@@ -0,0 +1,3 @@
$TESTDATA_DIR$/enumEntriesForJavaNotEnabled.kt
-d
$TEMP_DIR$
@@ -0,0 +1,6 @@
@OptIn(ExperimentalStdlibApi::class)
fun box(): String {
val entries = java.util.concurrent.TimeUnit.entries
return "OK"
}
@@ -0,0 +1,4 @@
compiler/testData/cli/jvm/enumEntriesForJavaNotEnabled.kt:4:49: error: unresolved reference: entries
val entries = java.util.concurrent.TimeUnit.entries
^
COMPILATION_ERROR
+3
View File
@@ -0,0 +1,3 @@
$TESTDATA_DIR$/enumEntriesNotEnabled.kt
-d
$TEMP_DIR$
+9
View File
@@ -0,0 +1,9 @@
enum class MyEnum {
OK, NOPE
}
@OptIn(ExperimentalStdlibApi::class)
fun box(): String {
val entries = MyEnum.entries
return "OK"
}
+4
View File
@@ -0,0 +1,4 @@
compiler/testData/cli/jvm/enumEntriesNotEnabled.kt:7:26: error: unresolved reference: entries
val entries = MyEnum.entries
^
COMPILATION_ERROR