JVM_IR: cast argument of enumValueOf to String in bytecode
Generic functions and implicit casts may return a supertype instead. #KT-45865 Fixed
This commit is contained in:
+6
@@ -14104,6 +14104,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/enum/enumShort.kt");
|
runTest("compiler/testData/codegen/box/enum/enumShort.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("enumValueOf.kt")
|
||||||
|
public void testEnumValueOf() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/enumValueOf.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("enumWithLambdaParameter.kt")
|
@TestMetadata("enumWithLambdaParameter.kt")
|
||||||
public void testEnumWithLambdaParameter() throws Exception {
|
public void testEnumWithLambdaParameter() throws Exception {
|
||||||
|
|||||||
+3
-2
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.backend.jvm.intrinsics
|
|||||||
import org.jetbrains.kotlin.backend.jvm.codegen.BlockInfo
|
import org.jetbrains.kotlin.backend.jvm.codegen.BlockInfo
|
||||||
import org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen
|
import org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen
|
||||||
import org.jetbrains.kotlin.backend.jvm.codegen.MaterialValue
|
import org.jetbrains.kotlin.backend.jvm.codegen.MaterialValue
|
||||||
import org.jetbrains.kotlin.backend.jvm.codegen.materialized
|
import org.jetbrains.kotlin.backend.jvm.codegen.materializedAt
|
||||||
import org.jetbrains.kotlin.codegen.AsmUtil
|
import org.jetbrains.kotlin.codegen.AsmUtil
|
||||||
import org.jetbrains.kotlin.codegen.inline.ReifiedTypeInliner
|
import org.jetbrains.kotlin.codegen.inline.ReifiedTypeInliner
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
|
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
|
||||||
@@ -18,7 +18,8 @@ import org.jetbrains.org.objectweb.asm.Type
|
|||||||
object EnumValueOf : IntrinsicMethod() {
|
object EnumValueOf : IntrinsicMethod() {
|
||||||
override fun invoke(expression: IrFunctionAccessExpression, codegen: ExpressionCodegen, data: BlockInfo) = with(codegen) {
|
override fun invoke(expression: IrFunctionAccessExpression, codegen: ExpressionCodegen, data: BlockInfo) = with(codegen) {
|
||||||
val type = expression.getTypeArgument(0)!!
|
val type = expression.getTypeArgument(0)!!
|
||||||
val result = expression.getValueArgument(0)!!.accept(this, data).materialized()
|
val result = expression.getValueArgument(0)!!.accept(this, data)
|
||||||
|
.materializedAt(AsmTypes.JAVA_STRING_TYPE, codegen.context.irBuiltIns.stringType)
|
||||||
if (type.isReifiedTypeParameter) {
|
if (type.isReifiedTypeParameter) {
|
||||||
// Note that the inliner expects exactly the following sequence of instructions.
|
// Note that the inliner expects exactly the following sequence of instructions.
|
||||||
// <REIFIED-OPERATIONS-MARKER>
|
// <REIFIED-OPERATIONS-MARKER>
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// IGNORE_BACKEND: WASM
|
||||||
|
enum class E { OK }
|
||||||
|
|
||||||
|
fun <T> id(x: T) = x
|
||||||
|
|
||||||
|
fun box() = enumValueOf<E>(id("OK")).name
|
||||||
+6
@@ -14104,6 +14104,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/enum/enumShort.kt");
|
runTest("compiler/testData/codegen/box/enum/enumShort.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("enumValueOf.kt")
|
||||||
|
public void testEnumValueOf() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/enumValueOf.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("enumWithLambdaParameter.kt")
|
@TestMetadata("enumWithLambdaParameter.kt")
|
||||||
public void testEnumWithLambdaParameter() throws Exception {
|
public void testEnumWithLambdaParameter() throws Exception {
|
||||||
|
|||||||
+6
@@ -14104,6 +14104,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/enum/enumShort.kt");
|
runTest("compiler/testData/codegen/box/enum/enumShort.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("enumValueOf.kt")
|
||||||
|
public void testEnumValueOf() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/enumValueOf.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("enumWithLambdaParameter.kt")
|
@TestMetadata("enumWithLambdaParameter.kt")
|
||||||
public void testEnumWithLambdaParameter() throws Exception {
|
public void testEnumWithLambdaParameter() throws Exception {
|
||||||
|
|||||||
+5
@@ -11548,6 +11548,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/enum/enumShort.kt");
|
runTest("compiler/testData/codegen/box/enum/enumShort.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("enumValueOf.kt")
|
||||||
|
public void testEnumValueOf() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/enumValueOf.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("enumWithLambdaParameter.kt")
|
@TestMetadata("enumWithLambdaParameter.kt")
|
||||||
public void testEnumWithLambdaParameter() throws Exception {
|
public void testEnumWithLambdaParameter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -10347,6 +10347,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
|||||||
runTest("compiler/testData/codegen/box/enum/enumShort.kt");
|
runTest("compiler/testData/codegen/box/enum/enumShort.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("enumValueOf.kt")
|
||||||
|
public void testEnumValueOf() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/enumValueOf.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("enumWithLambdaParameter.kt")
|
@TestMetadata("enumWithLambdaParameter.kt")
|
||||||
public void testEnumWithLambdaParameter() throws Exception {
|
public void testEnumWithLambdaParameter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
||||||
|
|||||||
Generated
+5
@@ -9768,6 +9768,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/enum/enumShort.kt");
|
runTest("compiler/testData/codegen/box/enum/enumShort.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("enumValueOf.kt")
|
||||||
|
public void testEnumValueOf() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/enumValueOf.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("enumWithLambdaParameter.kt")
|
@TestMetadata("enumWithLambdaParameter.kt")
|
||||||
public void testEnumWithLambdaParameter() throws Exception {
|
public void testEnumWithLambdaParameter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
||||||
|
|||||||
Generated
+5
@@ -9768,6 +9768,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/enum/enumShort.kt");
|
runTest("compiler/testData/codegen/box/enum/enumShort.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("enumValueOf.kt")
|
||||||
|
public void testEnumValueOf() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/enumValueOf.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("enumWithLambdaParameter.kt")
|
@TestMetadata("enumWithLambdaParameter.kt")
|
||||||
public void testEnumWithLambdaParameter() throws Exception {
|
public void testEnumWithLambdaParameter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+5
@@ -4727,6 +4727,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/enum/enumShort.kt");
|
runTest("compiler/testData/codegen/box/enum/enumShort.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("enumValueOf.kt")
|
||||||
|
public void testEnumValueOf() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/enumValueOf.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("enumWithLambdaParameter.kt")
|
@TestMetadata("enumWithLambdaParameter.kt")
|
||||||
public void testEnumWithLambdaParameter() throws Exception {
|
public void testEnumWithLambdaParameter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user