JVM_IR KT-32115 fix $$delegatedProperties initialization in enum

This commit is contained in:
Dmitry Petrov
2020-12-30 12:15:12 +03:00
committed by TeamCityServer
parent 3e3ffee2a0
commit 7fa04afda2
9 changed files with 54 additions and 4 deletions
@@ -10030,6 +10030,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/delegatedProperty/delegateWithPrivateSet.kt");
}
@TestMetadata("delegatedPropertyInEnum.kt")
public void testDelegatedPropertyInEnum() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/delegatedPropertyInEnum.kt");
}
@TestMetadata("extensionDelegatesWithSameNames.kt")
public void testExtensionDelegatesWithSameNames() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/extensionDelegatesWithSameNames.kt");
@@ -30,10 +30,11 @@ class StaticInitializersLowering(override val context: JvmBackendContext) : Init
if (staticInitializerStatements.isNotEmpty()) {
staticInitializerStatements.sortBy {
when ((it as? IrSetField)?.symbol?.owner?.origin) {
IrDeclarationOrigin.FIELD_FOR_ENUM_ENTRY -> 1
IrDeclarationOrigin.FIELD_FOR_ENUM_VALUES -> 2
IrDeclarationOrigin.FIELD_FOR_OBJECT_INSTANCE -> 3
else -> 4
JvmLoweredDeclarationOrigin.GENERATED_PROPERTY_REFERENCE -> 1
IrDeclarationOrigin.FIELD_FOR_ENUM_ENTRY -> 2
IrDeclarationOrigin.FIELD_FOR_ENUM_VALUES -> 3
IrDeclarationOrigin.FIELD_FOR_OBJECT_INSTANCE -> 4
else -> 5
}
}
irClass.addFunction {
@@ -0,0 +1,14 @@
// IGNORE_BACKEND: JVM
// IGNORE_LIGHT_ANALYSIS
object D {
operator fun getValue(a: Any?, b: Any?): String = "OK"
}
enum class A {
GOO;
val a by D
val b = a
}
fun box() = A.GOO.b
@@ -10030,6 +10030,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/delegatedProperty/delegateWithPrivateSet.kt");
}
@TestMetadata("delegatedPropertyInEnum.kt")
public void testDelegatedPropertyInEnum() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/delegatedPropertyInEnum.kt");
}
@TestMetadata("extensionDelegatesWithSameNames.kt")
public void testExtensionDelegatesWithSameNames() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/extensionDelegatesWithSameNames.kt");
@@ -9957,6 +9957,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class DelegatedProperty extends AbstractLightAnalysisModeTest {
@TestMetadata("delegatedPropertyInEnum.kt")
public void ignoreDelegatedPropertyInEnum() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/delegatedPropertyInEnum.kt");
}
@TestMetadata("genericDelegateUncheckedCast2.kt")
public void ignoreGenericDelegateUncheckedCast2() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/genericDelegateUncheckedCast2.kt");
@@ -10030,6 +10030,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/delegatedProperty/delegateWithPrivateSet.kt");
}
@TestMetadata("delegatedPropertyInEnum.kt")
public void testDelegatedPropertyInEnum() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/delegatedPropertyInEnum.kt");
}
@TestMetadata("extensionDelegatesWithSameNames.kt")
public void testExtensionDelegatesWithSameNames() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/extensionDelegatesWithSameNames.kt");
@@ -8515,6 +8515,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/delegatedProperty/delegateWithPrivateSet.kt");
}
@TestMetadata("delegatedPropertyInEnum.kt")
public void testDelegatedPropertyInEnum() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/delegatedPropertyInEnum.kt");
}
@TestMetadata("extensionDelegatesWithSameNames.kt")
public void testExtensionDelegatesWithSameNames() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/extensionDelegatesWithSameNames.kt");
@@ -8515,6 +8515,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/delegatedProperty/delegateWithPrivateSet.kt");
}
@TestMetadata("delegatedPropertyInEnum.kt")
public void testDelegatedPropertyInEnum() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/delegatedPropertyInEnum.kt");
}
@TestMetadata("extensionDelegatesWithSameNames.kt")
public void testExtensionDelegatesWithSameNames() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/extensionDelegatesWithSameNames.kt");
@@ -8515,6 +8515,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/delegatedProperty/delegateWithPrivateSet.kt");
}
@TestMetadata("delegatedPropertyInEnum.kt")
public void testDelegatedPropertyInEnum() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/delegatedPropertyInEnum.kt");
}
@TestMetadata("extensionDelegatesWithSameNames.kt")
public void testExtensionDelegatesWithSameNames() throws Exception {
runTest("compiler/testData/codegen/box/delegatedProperty/extensionDelegatesWithSameNames.kt");