FIR2IR fix enum special methods generation

This commit is contained in:
Dmitry Petrov
2021-11-22 17:10:25 +03:00
committed by Space
parent 2a263eca65
commit 2179987de7
10 changed files with 146 additions and 12 deletions
+14
View File
@@ -0,0 +1,14 @@
// TARGET_BACKEND: JVM
// FILE: E.java
public enum E {
OK();
public static String valueOf(E x) {
return x.toString();
}
}
// FILE: test.kt
// check that both 'valueOf(String): E' and 'valueOf(E): String' are invoked correctly
fun box() =
E.valueOf(E.valueOf("OK"))
-4
View File
@@ -1,8 +1,4 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// FIR status: V
// Caused by: java.util.NoSuchElementException: Sequence contains no element matching the predicate.
// at org.jetbrains.kotlin.backend.jvm.lower.MappedEnumWhenLowering.visitClassNew(MappedEnumWhenLowering.kt:232)
// FILE: E.java
public enum E {
A();
+18
View File
@@ -0,0 +1,18 @@
// TARGET_BACKEND: JVM
// FILE: E.java
public enum E {
A();
public static String values(String s) {
return s;
}
}
// FILE: test.kt
fun f(e: E) = when (e) {
E.A -> E.values("OK")
}
fun box(): String {
return f(E.A)
}
+17
View File
@@ -0,0 +1,17 @@
// TARGET_BACKEND: JVM
// FILE: E.java
public enum E {
OK(), A();
public static void values(boolean b) {}
}
// FILE: test.kt
fun f(e: E) = when (e) {
E.A -> E.values()[0].toString()
else -> "?"
}
fun box(): String {
return f(E.A)
}