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:
Alexander Udalov
2023-07-19 16:08:36 +02:00
committed by Space Team
parent c94c5a7d58
commit 874d1c514a
36 changed files with 652 additions and 4 deletions
@@ -359,6 +359,16 @@ class ReifiedTypeInliner<KT : KotlinTypeMarker>(
val desc = getSpecialEnumFunDescriptor(parameter, false)
instructions.insert(insn, MethodInsnNode(Opcodes.INVOKESTATIC, parameter.internalName, "values", desc, false))
return true
} else if (next1.opcode == Opcodes.ACONST_NULL && next2.opcode == Opcodes.CHECKCAST) {
instructions.remove(next1)
instructions.remove(next2)
// TODO: support enumEntries for Java enums.
instructions.insert(
insn, MethodInsnNode(
Opcodes.INVOKESTATIC, parameter.internalName, "getEntries", Type.getMethodDescriptor(AsmTypes.ENUM_ENTRIES), false
)
)
return true
}
return false