JVM: support enumEntries intrinsic for Kotlin enums
Implementation is very similar to the `enumValues` intrinsic. Java enums and old (pre-1.9) Kotlin enums will be supported in a subsequent commit. #KT-59710
This commit is contained in:
committed by
Space Team
parent
c94c5a7d58
commit
874d1c514a
@@ -0,0 +1,33 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// !OPT_IN: kotlin.ExperimentalStdlibApi
|
||||
// WITH_STDLIB
|
||||
// FILE: test/Z.java
|
||||
|
||||
package test;
|
||||
|
||||
public enum Z {
|
||||
O, K
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") // TODO: remove once KT-53154 is fixed.
|
||||
|
||||
package test
|
||||
|
||||
import kotlin.enums.enumEntries
|
||||
|
||||
inline fun <reified T : Enum<T>> myEntries(): String {
|
||||
val values = enumEntries<T>()
|
||||
return values.joinToString("")
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return myEntries<Z>()
|
||||
}
|
||||
Reference in New Issue
Block a user