fix(KT-45056, KT-47516): use enum as an IR class instead of enum entity class.
This commit is contained in:
+12
@@ -15150,6 +15150,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("getEnumEntityByOrdinal.kt")
|
||||||
|
public void testGetEnumEntityByOrdinal() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/getEnumEntityByOrdinal.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("inPackage.kt")
|
@TestMetadata("inPackage.kt")
|
||||||
public void testInPackage() throws Exception {
|
public void testInPackage() throws Exception {
|
||||||
@@ -15414,6 +15420,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/enum/ordinal.kt");
|
runTest("compiler/testData/codegen/box/enum/ordinal.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("ordinalsWithEnumEntitiesOverrides.kt")
|
||||||
|
public void testOrdinalsWithEnumEntitiesOverrides() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/ordinalsWithEnumEntitiesOverrides.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("overloadedEnumValues.kt")
|
@TestMetadata("overloadedEnumValues.kt")
|
||||||
public void testOverloadedEnumValues() throws Exception {
|
public void testOverloadedEnumValues() throws Exception {
|
||||||
|
|||||||
+2
-2
@@ -176,7 +176,7 @@ class EnumClassConstructorBodyTransformer(val context: JsCommonBackendContext) :
|
|||||||
irClass.correspondingEntry?.let { enumEntry ->
|
irClass.correspondingEntry?.let { enumEntry ->
|
||||||
// Lower `IrEnumConstructorCall`s inside of enum entry class constructors to corresponding `IrDelegatingConstructorCall`s.
|
// Lower `IrEnumConstructorCall`s inside of enum entry class constructors to corresponding `IrDelegatingConstructorCall`s.
|
||||||
// Add `name` and `ordinal` parameters.
|
// Add `name` and `ordinal` parameters.
|
||||||
lowerEnumEntryClassConstructors(irClass, enumEntry, container)
|
lowerEnumEntryClassConstructors(enumEntry.parentAsClass, enumEntry, container)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ class EnumClassConstructorBodyTransformer(val context: JsCommonBackendContext) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private inner class IrEnumEntryClassConstructorTransformer(
|
private inner class IrEnumEntryClassConstructorTransformer(
|
||||||
val irClass: IrClass,
|
irClass: IrClass,
|
||||||
val entry: IrEnumEntry,
|
val entry: IrEnumEntry,
|
||||||
val isInsideConstructor: Boolean
|
val isInsideConstructor: Boolean
|
||||||
) :
|
) :
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
enum class X {
|
||||||
|
B {
|
||||||
|
override val value2 = "K"
|
||||||
|
override val value = "O" + B.value2.get(X.B.ordinal).toString()
|
||||||
|
};
|
||||||
|
|
||||||
|
abstract val value2: String
|
||||||
|
abstract val value: String
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box() = X.B.value
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
package foo
|
||||||
|
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
enum class TestA {
|
||||||
|
FIRST {
|
||||||
|
override val label: String = "first A"
|
||||||
|
},
|
||||||
|
SECOND {
|
||||||
|
override val label: String = "second A"
|
||||||
|
},
|
||||||
|
THIRD {
|
||||||
|
override val label: String = "third A"
|
||||||
|
};
|
||||||
|
|
||||||
|
abstract val label: String
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class TestB(val label: String) {
|
||||||
|
FIRST("first B"),
|
||||||
|
SECOND("second B"),
|
||||||
|
THIRD("third B");
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
assertEquals(TestA.FIRST.label, "first A")
|
||||||
|
assertEquals(TestA.SECOND.label, "second A")
|
||||||
|
assertEquals(TestA.THIRD.label, "third A")
|
||||||
|
|
||||||
|
assertEquals(TestA.FIRST.ordinal, 0)
|
||||||
|
assertEquals(TestA.SECOND.ordinal, 1)
|
||||||
|
assertEquals(TestA.THIRD.ordinal, 2)
|
||||||
|
|
||||||
|
assertEquals(TestB.FIRST.label,"first B")
|
||||||
|
assertEquals(TestB.SECOND.label,"second B")
|
||||||
|
assertEquals(TestB.THIRD.label,"third B")
|
||||||
|
|
||||||
|
assertEquals(TestB.FIRST.ordinal, 0)
|
||||||
|
assertEquals(TestB.SECOND.ordinal, 1)
|
||||||
|
assertEquals(TestB.THIRD.ordinal, 2)
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+12
@@ -15072,6 +15072,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("getEnumEntityByOrdinal.kt")
|
||||||
|
public void testGetEnumEntityByOrdinal() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/getEnumEntityByOrdinal.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("inPackage.kt")
|
@TestMetadata("inPackage.kt")
|
||||||
public void testInPackage() throws Exception {
|
public void testInPackage() throws Exception {
|
||||||
@@ -15336,6 +15342,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/enum/ordinal.kt");
|
runTest("compiler/testData/codegen/box/enum/ordinal.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("ordinalsWithEnumEntitiesOverrides.kt")
|
||||||
|
public void testOrdinalsWithEnumEntitiesOverrides() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/ordinalsWithEnumEntitiesOverrides.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("overloadedEnumValues.kt")
|
@TestMetadata("overloadedEnumValues.kt")
|
||||||
public void testOverloadedEnumValues() throws Exception {
|
public void testOverloadedEnumValues() throws Exception {
|
||||||
|
|||||||
+12
@@ -15150,6 +15150,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("getEnumEntityByOrdinal.kt")
|
||||||
|
public void testGetEnumEntityByOrdinal() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/getEnumEntityByOrdinal.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("inPackage.kt")
|
@TestMetadata("inPackage.kt")
|
||||||
public void testInPackage() throws Exception {
|
public void testInPackage() throws Exception {
|
||||||
@@ -15414,6 +15420,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/enum/ordinal.kt");
|
runTest("compiler/testData/codegen/box/enum/ordinal.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("ordinalsWithEnumEntitiesOverrides.kt")
|
||||||
|
public void testOrdinalsWithEnumEntitiesOverrides() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/ordinalsWithEnumEntitiesOverrides.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("overloadedEnumValues.kt")
|
@TestMetadata("overloadedEnumValues.kt")
|
||||||
public void testOverloadedEnumValues() throws Exception {
|
public void testOverloadedEnumValues() throws Exception {
|
||||||
|
|||||||
+10
@@ -12367,6 +12367,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("getEnumEntityByOrdinal.kt")
|
||||||
|
public void testGetEnumEntityByOrdinal() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/getEnumEntityByOrdinal.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inPackage.kt")
|
@TestMetadata("inPackage.kt")
|
||||||
public void testInPackage() throws Exception {
|
public void testInPackage() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/inPackage.kt");
|
runTest("compiler/testData/codegen/box/enum/inPackage.kt");
|
||||||
@@ -12587,6 +12592,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/enum/ordinal.kt");
|
runTest("compiler/testData/codegen/box/enum/ordinal.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ordinalsWithEnumEntitiesOverrides.kt")
|
||||||
|
public void testOrdinalsWithEnumEntitiesOverrides() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/ordinalsWithEnumEntitiesOverrides.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("overloadedEnumValues.kt")
|
@TestMetadata("overloadedEnumValues.kt")
|
||||||
public void testOverloadedEnumValues() throws Exception {
|
public void testOverloadedEnumValues() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/overloadedEnumValues.kt");
|
runTest("compiler/testData/codegen/box/enum/overloadedEnumValues.kt");
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+10
@@ -11036,6 +11036,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
|||||||
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("getEnumEntityByOrdinal.kt")
|
||||||
|
public void testGetEnumEntityByOrdinal() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/getEnumEntityByOrdinal.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inPackage.kt")
|
@TestMetadata("inPackage.kt")
|
||||||
public void testInPackage() throws Exception {
|
public void testInPackage() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/inPackage.kt");
|
runTest("compiler/testData/codegen/box/enum/inPackage.kt");
|
||||||
@@ -11226,6 +11231,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
|||||||
runTest("compiler/testData/codegen/box/enum/ordinal.kt");
|
runTest("compiler/testData/codegen/box/enum/ordinal.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ordinalsWithEnumEntitiesOverrides.kt")
|
||||||
|
public void testOrdinalsWithEnumEntitiesOverrides() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/ordinalsWithEnumEntitiesOverrides.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("overloadedEnumValues.kt")
|
@TestMetadata("overloadedEnumValues.kt")
|
||||||
public void testOverloadedEnumValues() throws Exception {
|
public void testOverloadedEnumValues() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/overloadedEnumValues.kt");
|
runTest("compiler/testData/codegen/box/enum/overloadedEnumValues.kt");
|
||||||
|
|||||||
Generated
+10
@@ -10442,6 +10442,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("getEnumEntityByOrdinal.kt")
|
||||||
|
public void testGetEnumEntityByOrdinal() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/getEnumEntityByOrdinal.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inPackage.kt")
|
@TestMetadata("inPackage.kt")
|
||||||
public void testInPackage() throws Exception {
|
public void testInPackage() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/inPackage.kt");
|
runTest("compiler/testData/codegen/box/enum/inPackage.kt");
|
||||||
@@ -10632,6 +10637,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/enum/ordinal.kt");
|
runTest("compiler/testData/codegen/box/enum/ordinal.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ordinalsWithEnumEntitiesOverrides.kt")
|
||||||
|
public void testOrdinalsWithEnumEntitiesOverrides() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/ordinalsWithEnumEntitiesOverrides.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("overloadedEnumValues.kt")
|
@TestMetadata("overloadedEnumValues.kt")
|
||||||
public void testOverloadedEnumValues() throws Exception {
|
public void testOverloadedEnumValues() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/overloadedEnumValues.kt");
|
runTest("compiler/testData/codegen/box/enum/overloadedEnumValues.kt");
|
||||||
|
|||||||
Generated
+10
@@ -10407,6 +10407,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("getEnumEntityByOrdinal.kt")
|
||||||
|
public void testGetEnumEntityByOrdinal() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/getEnumEntityByOrdinal.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inPackage.kt")
|
@TestMetadata("inPackage.kt")
|
||||||
public void testInPackage() throws Exception {
|
public void testInPackage() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/inPackage.kt");
|
runTest("compiler/testData/codegen/box/enum/inPackage.kt");
|
||||||
@@ -10597,6 +10602,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/enum/ordinal.kt");
|
runTest("compiler/testData/codegen/box/enum/ordinal.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ordinalsWithEnumEntitiesOverrides.kt")
|
||||||
|
public void testOrdinalsWithEnumEntitiesOverrides() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/ordinalsWithEnumEntitiesOverrides.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("overloadedEnumValues.kt")
|
@TestMetadata("overloadedEnumValues.kt")
|
||||||
public void testOverloadedEnumValues() throws Exception {
|
public void testOverloadedEnumValues() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/overloadedEnumValues.kt");
|
runTest("compiler/testData/codegen/box/enum/overloadedEnumValues.kt");
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+10
@@ -7186,6 +7186,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("getEnumEntityByOrdinal.kt")
|
||||||
|
public void testGetEnumEntityByOrdinal() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/getEnumEntityByOrdinal.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inPackage.kt")
|
@TestMetadata("inPackage.kt")
|
||||||
public void testInPackage() throws Exception {
|
public void testInPackage() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/inPackage.kt");
|
runTest("compiler/testData/codegen/box/enum/inPackage.kt");
|
||||||
@@ -7376,6 +7381,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/enum/ordinal.kt");
|
runTest("compiler/testData/codegen/box/enum/ordinal.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ordinalsWithEnumEntitiesOverrides.kt")
|
||||||
|
public void testOrdinalsWithEnumEntitiesOverrides() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/enum/ordinalsWithEnumEntitiesOverrides.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("overloadedEnumValues.kt")
|
@TestMetadata("overloadedEnumValues.kt")
|
||||||
public void testOverloadedEnumValues() throws Exception {
|
public void testOverloadedEnumValues() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/overloadedEnumValues.kt");
|
runTest("compiler/testData/codegen/box/enum/overloadedEnumValues.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user