IR: Lower shared variables in enum entries (KT-46605)

This commit is contained in:
Steven Schäfer
2021-05-17 12:33:09 +02:00
committed by Alexander Udalov
parent b78c645fb0
commit 60bc0f4baf
10 changed files with 61 additions and 4 deletions
@@ -14538,6 +14538,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/enum/kt44744_innerClass.kt");
}
@Test
@TestMetadata("kt46605.kt")
public void testKt46605() throws Exception {
runTest("compiler/testData/codegen/box/enum/kt46605.kt");
}
@Test
@TestMetadata("kt7257.kt")
public void testKt7257() throws Exception {
@@ -40,10 +40,7 @@ val sharedVariablesPhase = makeIrFilePhase(
class SharedVariablesLowering(val context: BackendContext) : BodyLoweringPass {
override fun lower(irBody: IrBody, container: IrDeclaration) {
// TODO remove this condition
if (container is IrFunction || container is IrField || container is IrAnonymousInitializer) {
SharedVariablesTransformer(irBody, container).lowerSharedVariables()
}
SharedVariablesTransformer(irBody, container).lowerSharedVariables()
}
private inner class SharedVariablesTransformer(val irBody: IrBody, val irDeclaration: IrDeclaration) {
+17
View File
@@ -0,0 +1,17 @@
fun call(f: () -> Unit) {
f()
}
enum class E(val f: () -> String) {
A({
var value = "Fail"
call {
value = "OK"
}
value
})
}
fun box(): String {
return E.A.f()
}
@@ -14538,6 +14538,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/enum/kt44744_innerClass.kt");
}
@Test
@TestMetadata("kt46605.kt")
public void testKt46605() throws Exception {
runTest("compiler/testData/codegen/box/enum/kt46605.kt");
}
@Test
@TestMetadata("kt7257.kt")
public void testKt7257() throws Exception {
@@ -14538,6 +14538,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/enum/kt44744_innerClass.kt");
}
@Test
@TestMetadata("kt46605.kt")
public void testKt46605() throws Exception {
runTest("compiler/testData/codegen/box/enum/kt46605.kt");
}
@Test
@TestMetadata("kt7257.kt")
public void testKt7257() throws Exception {
@@ -11899,6 +11899,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/enum/kt44744_innerClass.kt");
}
@TestMetadata("kt46605.kt")
public void testKt46605() throws Exception {
runTest("compiler/testData/codegen/box/enum/kt46605.kt");
}
@TestMetadata("kt7257.kt")
public void testKt7257() throws Exception {
runTest("compiler/testData/codegen/box/enum/kt7257.kt");
@@ -10633,6 +10633,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/enum/kt44744_innerClass.kt");
}
@TestMetadata("kt46605.kt")
public void testKt46605() throws Exception {
runTest("compiler/testData/codegen/box/enum/kt46605.kt");
}
@TestMetadata("kt7257.kt")
public void testKt7257() throws Exception {
runTest("compiler/testData/codegen/box/enum/kt7257.kt");
@@ -10039,6 +10039,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/enum/kt44744_innerClass.kt");
}
@TestMetadata("kt46605.kt")
public void testKt46605() throws Exception {
runTest("compiler/testData/codegen/box/enum/kt46605.kt");
}
@TestMetadata("kt7257.kt")
public void testKt7257() throws Exception {
runTest("compiler/testData/codegen/box/enum/kt7257.kt");
@@ -10039,6 +10039,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/enum/kt44744_innerClass.kt");
}
@TestMetadata("kt46605.kt")
public void testKt46605() throws Exception {
runTest("compiler/testData/codegen/box/enum/kt46605.kt");
}
@TestMetadata("kt7257.kt")
public void testKt7257() throws Exception {
runTest("compiler/testData/codegen/box/enum/kt7257.kt");
@@ -4902,6 +4902,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/enum/kt44744_innerClass.kt");
}
@TestMetadata("kt46605.kt")
public void testKt46605() throws Exception {
runTest("compiler/testData/codegen/box/enum/kt46605.kt");
}
@TestMetadata("kt7257.kt")
public void testKt7257() throws Exception {
runTest("compiler/testData/codegen/box/enum/kt7257.kt");