Optimize ir interpretation of Enum.name

There is no need to create honest object in case of such simple
calculation. Furthermore, it can be harmful if enum class has
non-constant initializer or property.

#KT-53480 Fixed
This commit is contained in:
Ivan Kylchik
2022-08-10 17:06:03 +03:00
parent 0efca602a0
commit 45b89de9f4
11 changed files with 95 additions and 31 deletions
+15
View File
@@ -0,0 +1,15 @@
// TARGET_BACKEND: JVM_IR
// FILE: J.java
public class J {
public static int f() { return 0; }
}
// FILE: Main.kt
enum class A {
OK;
val x = J.f()
}
fun box(): String {
return A.OK.name
}