Make enum entries to be interpreted in right order
#KT-53727 Fixed
This commit is contained in:
+6
@@ -100,6 +100,12 @@ public class LoweredIrInterpreterTestGenerated extends AbstractLoweredIrInterpre
|
|||||||
runTest("compiler/testData/ir/loweredIr/interpreter/kCallableName.kt");
|
runTest("compiler/testData/ir/loweredIr/interpreter/kCallableName.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt53272.kt")
|
||||||
|
public void testKt53272() throws Exception {
|
||||||
|
runTest("compiler/testData/ir/loweredIr/interpreter/kt53272.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("longOperations.kt")
|
@TestMetadata("longOperations.kt")
|
||||||
public void testLongOperations() throws Exception {
|
public void testLongOperations() throws Exception {
|
||||||
|
|||||||
+1
-1
@@ -259,7 +259,7 @@ private fun unfoldGetEnumValue(expression: IrGetEnumValue, environment: IrInterp
|
|||||||
callStack.pushSimpleInstruction(expression)
|
callStack.pushSimpleInstruction(expression)
|
||||||
val enumEntry = expression.symbol.owner
|
val enumEntry = expression.symbol.owner
|
||||||
val enumClass = enumEntry.symbol.owner.parentAsClass
|
val enumClass = enumEntry.symbol.owner.parentAsClass
|
||||||
enumClass.declarations.filterIsInstance<IrEnumEntry>().forEach {
|
enumClass.declarations.filterIsInstance<IrEnumEntry>().reversed().forEach {
|
||||||
callStack.pushSimpleInstruction(it)
|
callStack.pushSimpleInstruction(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -398,6 +398,7 @@ class IrInterpreter(internal val environment: IrInterpreterEnvironment, internal
|
|||||||
?: (enumInitializer as IrBlock).statements.filterIsInstance<IrEnumConstructorCall>().single()
|
?: (enumInitializer as IrBlock).statements.filterIsInstance<IrEnumConstructorCall>().single()
|
||||||
val enumSuperCall = enumConstructorCall.getSuperEnumCall()
|
val enumSuperCall = enumConstructorCall.getSuperEnumCall()
|
||||||
|
|
||||||
|
// TODO must call this function even after exception has occurred or else data will be corrupted
|
||||||
val cleanEnumSuperCall = fun() {
|
val cleanEnumSuperCall = fun() {
|
||||||
enumSuperCall.apply { (0 until this.valueArgumentsCount).forEach { putValueArgument(it, null) } } // restore to null
|
enumSuperCall.apply { (0 until this.valueArgumentsCount).forEach { putValueArgument(it, null) } } // restore to null
|
||||||
callStack.popState() // result of constructor must be dropped, because next instruction will be `IrGetEnumValue`
|
callStack.popState() // result of constructor must be dropped, because next instruction will be `IrGetEnumValue`
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ class IrConstTransformer(
|
|||||||
onError(original, this)
|
onError(original, this)
|
||||||
return when (mode) {
|
return when (mode) {
|
||||||
// need to pass any const value to be able to get some bytecode and then report error
|
// need to pass any const value to be able to get some bytecode and then report error
|
||||||
EvaluationMode.ONLY_INTRINSIC_CONST -> IrConstImpl.int(startOffset, endOffset, type, 0)
|
EvaluationMode.ONLY_INTRINSIC_CONST -> IrConstImpl.constNull(startOffset, endOffset, type)
|
||||||
else -> original
|
else -> original
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// FILE: 1.kt
|
||||||
|
|
||||||
|
const val name = E.OK.name
|
||||||
|
fun box(): String = name
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
|
||||||
|
enum class E(val parent: E?) {
|
||||||
|
X(null),
|
||||||
|
OK(X),
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user