Support proper frame maps for enum valueOf

This commit is contained in:
Mikhael Bogdanov
2021-01-27 12:16:08 +01:00
parent 5b64ceceb3
commit 1a044e5af4
12 changed files with 93 additions and 0 deletions
@@ -84,6 +84,7 @@ private fun createSpecialEnumMethodBody(
Opcodes.INVOKESTATIC, ENUM_TYPE.internalName, "valueOf",
Type.getMethodDescriptor(ENUM_TYPE, JAVA_CLASS_TYPE, JAVA_STRING_TYPE), false
)
node.visitTypeInsn(Opcodes.CHECKCAST, ENUM_TYPE.internalName)
} else {
node.visitInsn(Opcodes.ICONST_0)
node.visitTypeInsn(Opcodes.ANEWARRAY, ENUM_TYPE.internalName)
@@ -3193,6 +3193,11 @@ public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxIn
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try.kt");
}
@TestMetadata("kt35511_try_valueOf.kt")
public void testKt35511_try_valueOf() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try_valueOf.kt");
}
@TestMetadata("kt6988.kt")
public void testKt6988() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt6988.kt");
@@ -0,0 +1,42 @@
// JVM_TARGET: 1.8
// FILE: 1.kt
// WITH_RUNTIME
package test
enum class Base(val value: String) {
OK("OK"),
B("FAIL");
}
enum class Base2(val value: String) {
A("OK2"),
B("FAIL2");
}
var result = "fail"
fun foo(base: Enum<*>) {
result = base.name
}
fun cond() = true
inline fun <reified T : Enum<T>, reified Y : Enum<Y>> process(name: String) {
val z = try {
enumValueOf<T>(name)
} catch (e: Exception) {
enumValueOf<Y>(name)
}
foo(z)
}
// FILE: 2.kt
import test.*
fun box(): String {
process<Base, Base2>("OK")
return result
}
@@ -3193,6 +3193,11 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try.kt");
}
@TestMetadata("kt35511_try_valueOf.kt")
public void testKt35511_try_valueOf() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try_valueOf.kt");
}
@TestMetadata("kt6988.kt")
public void testKt6988() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt6988.kt");
@@ -3193,6 +3193,11 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try.kt");
}
@TestMetadata("kt35511_try_valueOf.kt")
public void testKt35511_try_valueOf() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try_valueOf.kt");
}
@TestMetadata("kt6988.kt")
public void testKt6988() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt6988.kt");
@@ -3193,6 +3193,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try.kt");
}
@TestMetadata("kt35511_try_valueOf.kt")
public void testKt35511_try_valueOf() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try_valueOf.kt");
}
@TestMetadata("kt6988.kt")
public void testKt6988() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt6988.kt");
@@ -3193,6 +3193,11 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try.kt");
}
@TestMetadata("kt35511_try_valueOf.kt")
public void testKt35511_try_valueOf() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try_valueOf.kt");
}
@TestMetadata("kt6988.kt")
public void testKt6988() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt6988.kt");
@@ -3193,6 +3193,11 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try.kt");
}
@TestMetadata("kt35511_try_valueOf.kt")
public void testKt35511_try_valueOf() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try_valueOf.kt");
}
@TestMetadata("kt6988.kt")
public void testKt6988() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt6988.kt");
@@ -3193,6 +3193,11 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try.kt");
}
@TestMetadata("kt35511_try_valueOf.kt")
public void testKt35511_try_valueOf() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try_valueOf.kt");
}
@TestMetadata("kt6988.kt")
public void testKt6988() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt6988.kt");
@@ -2908,6 +2908,11 @@ public class IrJsCodegenInlineES6TestGenerated extends AbstractIrJsCodegenInline
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try.kt");
}
@TestMetadata("kt35511_try_valueOf.kt")
public void testKt35511_try_valueOf() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try_valueOf.kt");
}
@TestMetadata("kt7017.kt")
public void testKt7017() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt7017.kt");
@@ -2908,6 +2908,11 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try.kt");
}
@TestMetadata("kt35511_try_valueOf.kt")
public void testKt35511_try_valueOf() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try_valueOf.kt");
}
@TestMetadata("kt7017.kt")
public void testKt7017() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt7017.kt");
@@ -2908,6 +2908,11 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest {
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try.kt");
}
@TestMetadata("kt35511_try_valueOf.kt")
public void testKt35511_try_valueOf() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt35511_try_valueOf.kt");
}
@TestMetadata("kt7017.kt")
public void testKt7017() throws Exception {
runTest("compiler/testData/codegen/boxInline/reified/kt7017.kt");