IR: Lower shared variables in enum entries (KT-46605)
This commit is contained in:
committed by
Alexander Udalov
parent
b78c645fb0
commit
60bc0f4baf
+6
@@ -14538,6 +14538,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/enum/kt44744_innerClass.kt");
|
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
|
@Test
|
||||||
@TestMetadata("kt7257.kt")
|
@TestMetadata("kt7257.kt")
|
||||||
public void testKt7257() throws Exception {
|
public void testKt7257() throws Exception {
|
||||||
|
|||||||
+1
-4
@@ -40,10 +40,7 @@ val sharedVariablesPhase = makeIrFilePhase(
|
|||||||
class SharedVariablesLowering(val context: BackendContext) : BodyLoweringPass {
|
class SharedVariablesLowering(val context: BackendContext) : BodyLoweringPass {
|
||||||
|
|
||||||
override fun lower(irBody: IrBody, container: IrDeclaration) {
|
override fun lower(irBody: IrBody, container: IrDeclaration) {
|
||||||
// TODO remove this condition
|
SharedVariablesTransformer(irBody, container).lowerSharedVariables()
|
||||||
if (container is IrFunction || container is IrField || container is IrAnonymousInitializer) {
|
|
||||||
SharedVariablesTransformer(irBody, container).lowerSharedVariables()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class SharedVariablesTransformer(val irBody: IrBody, val irDeclaration: IrDeclaration) {
|
private inner class SharedVariablesTransformer(val irBody: IrBody, val irDeclaration: IrDeclaration) {
|
||||||
|
|||||||
+17
@@ -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()
|
||||||
|
}
|
||||||
+6
@@ -14538,6 +14538,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/enum/kt44744_innerClass.kt");
|
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
|
@Test
|
||||||
@TestMetadata("kt7257.kt")
|
@TestMetadata("kt7257.kt")
|
||||||
public void testKt7257() throws Exception {
|
public void testKt7257() throws Exception {
|
||||||
|
|||||||
+6
@@ -14538,6 +14538,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/enum/kt44744_innerClass.kt");
|
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
|
@Test
|
||||||
@TestMetadata("kt7257.kt")
|
@TestMetadata("kt7257.kt")
|
||||||
public void testKt7257() throws Exception {
|
public void testKt7257() throws Exception {
|
||||||
|
|||||||
+5
@@ -11899,6 +11899,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/enum/kt44744_innerClass.kt");
|
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")
|
@TestMetadata("kt7257.kt")
|
||||||
public void testKt7257() throws Exception {
|
public void testKt7257() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/kt7257.kt");
|
runTest("compiler/testData/codegen/box/enum/kt7257.kt");
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -10633,6 +10633,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
|||||||
runTest("compiler/testData/codegen/box/enum/kt44744_innerClass.kt");
|
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")
|
@TestMetadata("kt7257.kt")
|
||||||
public void testKt7257() throws Exception {
|
public void testKt7257() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/kt7257.kt");
|
runTest("compiler/testData/codegen/box/enum/kt7257.kt");
|
||||||
|
|||||||
Generated
+5
@@ -10039,6 +10039,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/enum/kt44744_innerClass.kt");
|
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")
|
@TestMetadata("kt7257.kt")
|
||||||
public void testKt7257() throws Exception {
|
public void testKt7257() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/kt7257.kt");
|
runTest("compiler/testData/codegen/box/enum/kt7257.kt");
|
||||||
|
|||||||
Generated
+5
@@ -10039,6 +10039,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/enum/kt44744_innerClass.kt");
|
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")
|
@TestMetadata("kt7257.kt")
|
||||||
public void testKt7257() throws Exception {
|
public void testKt7257() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/kt7257.kt");
|
runTest("compiler/testData/codegen/box/enum/kt7257.kt");
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+5
@@ -4902,6 +4902,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/enum/kt44744_innerClass.kt");
|
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")
|
@TestMetadata("kt7257.kt")
|
||||||
public void testKt7257() throws Exception {
|
public void testKt7257() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/enum/kt7257.kt");
|
runTest("compiler/testData/codegen/box/enum/kt7257.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user