Files
kotlin-fork/compiler/testData/codegen/bytecodeText/inline/entriesMappingOnCallSite.kt
T
Vsevolod Tolstopyatov c0f81cbc45 [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
2022-08-12 09:35:24 +00:00

32 lines
611 B
Kotlin
Vendored

// 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