[JVM] Improve code coverage of EntriesMapping

Ensure that when .entries is accessed from an inline function body
or lambda argument, EntriesMapping are properly generated and used
without excessive mappings and duplicated fields

#KT-53236
This commit is contained in:
Vsevolod Tolstopyatov
2022-07-22 17:31:56 +02:00
committed by Space
parent 8a181cf2bd
commit c0f81cbc45
21 changed files with 495 additions and 0 deletions
@@ -0,0 +1,31 @@
// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
// WITH_RUNTIME
// MODULE: lib
// FILE: 1.kt
enum class X {
O,
K
}
// MODULE: caller(lib)
// !LANGUAGE: +EnumEntries
// FILE: F.kt
inline fun test(idx: Int, block: () -> String): String {
return block()
}
@OptIn(ExperimentalStdlibApi::class)
fun box(): String {
return test(0) { X.entries[0].toString() } +
test(1) { X.entries[1].toString() }
}
// no additional mappings cause when in inline lambda (same module)
// 1 class FKt\$EntriesMappings
// 1 Lkotlin\/enums\/EnumEntries; entries\$0
// 0 Lkotlin\/enums\/EnumEntries; entries\$1