[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
@@ -70,6 +70,12 @@ object SpecialNames {
@JvmField
val RECEIVER = Name.special("<receiver>")
/**
* Kotlin-generated `entries` read-only property
*/
@JvmField
val ENUM_GET_ENTRIES = Name.special("<get-entries>")
/**
* Special name to store expressions used as indexes in subscription operators (`get` and `set`).
*
@@ -95,4 +101,4 @@ object SpecialNames {
fun isSafeIdentifier(name: Name): Boolean {
return name.asString().isNotEmpty() && !name.isSpecial
}
}
}