JVM: support enumEntries intrinsic for Java & old Kotlin enums

#KT-59710 Fixed
This commit is contained in:
Alexander Udalov
2023-07-20 00:52:22 +02:00
committed by Space Team
parent 874d1c514a
commit 971b4e63e7
25 changed files with 389 additions and 54 deletions
@@ -0,0 +1,29 @@
// TARGET_BACKEND: JVM_IR
// !OPT_IN: kotlin.ExperimentalStdlibApi
// WITH_STDLIB
// FILE: Z.java
public enum Z {
O, K
}
// FILE: box.kt
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") // TODO: remove once KT-53154 is fixed.
import kotlin.enums.*
fun callFromOtherFunctionInTheSameFile(): EnumEntries<Z> = enumEntries<Z>()
fun box(): String {
val z = enumEntries<Z>()
if (z.toString() != "[O, K]") return "Fail 1: $z"
val z2 = enumEntries<Z>()
if (z2 !== z) return "Fail 2: another instance of EnumEntries is created"
val z3 = callFromOtherFunctionInTheSameFile()
if (z3 !== z) return "Fail 3: another instance of EnumEntries is created"
return "OK"
}