Files
kotlin-fork/compiler/testData/codegen/box/enum/enumEntriesIntrinsicMultipleEnums.kt
T
Alexander Udalov db31f1f926 Tests: update some backend tests on enum entries
The enumEntriesIntrinsicMultipleEnums.kt test was supposed to check that
JVM backend generates 3 `$EntriesIntrinsicMappings` classes: for X, for
Y, and for Z. Mappings classes are generated for enums without
`entries`, i.e. Kotlin enums compiled without `EnumEntries` language
feature, and Java enums. The test incorrectly _enabled_ the language
feature for X though, and `$EntriesIntrinsicMappings` for X was
generated anyway because of KT-61208.

To keep the original intention of the test, I'm disabling the language
feature for X, so that it will be considered as enum without `entries`.
KT-61208 will be fixed in a separate commit (with separate tests).

The boxInline and bytecodeText tests changed their meaning when language
feature EnumEntries started to be enabled by default, so those changes
are a continuation to ebd43fc8c0. The behavior did not change after
enabling the feature, once again because of KT-61208.

Also, remove obsolete error suppressions which are no longer needed
after 64c8ce18a0.
2023-10-16 20:22:20 +00:00

49 lines
894 B
Kotlin
Vendored

// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
// CHECK_BYTECODE_LISTING
// ^ Check that there's only one $EntriesIntrinsicMappings class, with three fields (entries$0, entries$1, entries$2).
// MODULE: lib
// !LANGUAGE: -EnumEntries
// FILE: X.kt
enum class X {
X1, X2
}
// FILE: Y.java
public enum Y {
Y1, Y2
}
// FILE: Z.java
public enum Z {
Z1, Z2
}
// MODULE: box(lib)
// !LANGUAGE: +EnumEntries
// !OPT_IN: kotlin.ExperimentalStdlibApi
// FILE: box.kt
import kotlin.enums.enumEntries
fun box(): String {
val x = enumEntries<X>()
if (x.toString() != "[X1, X2]") return "Fail X: $x"
val y = enumEntries<Y>()
if (y.toString() != "[Y1, Y2]") return "Fail Y: $y"
val z = enumEntries<Z>()
if (z.toString() != "[Z1, Z2]") return "Fail Z: $z"
val xx = enumEntries<X>()
if (xx.toString() != "[X1, X2]") return "Fail X #2: $xx"
return "OK"
}