KT-52551 Create a static initialization section in case of delegation to a property reference from a file class
This commit is contained in:
committed by
teamcity
parent
0b9e5e14be
commit
2ceccec2b8
+6
@@ -14583,6 +14583,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
public void testWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/withSideEffects.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("withSideEffectsFromFileClass.kt")
|
||||
public void testWithSideEffectsFromFileClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/withSideEffectsFromFileClass.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+7
-1
@@ -172,7 +172,13 @@ private class PropertyReferenceDelegationTransformer(val context: JvmBackendCont
|
||||
// When the receiver is inlined, it can have side effects in form of class initialization, so it should be evaluated here.
|
||||
val receiverBlock = receiver.takeIf { backingField == null }?.let {
|
||||
val symbol = IrAnonymousInitializerSymbolImpl(parentAsClass.symbol)
|
||||
context.irFactory.createAnonymousInitializer(it.startOffset, it.endOffset, IrDeclarationOrigin.DEFINED, symbol).apply {
|
||||
context.irFactory.createAnonymousInitializer(
|
||||
it.startOffset,
|
||||
it.endOffset,
|
||||
IrDeclarationOrigin.DEFINED,
|
||||
symbol,
|
||||
parentAsClass.isFacadeClass
|
||||
).apply {
|
||||
body = context.irFactory.createBlockBody(startOffset, endOffset, listOf(it.inline(null, null)))
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// WITH_STDLIB
|
||||
var initialized = false
|
||||
|
||||
object O {
|
||||
val z = "OK"
|
||||
init { initialized = true }
|
||||
}
|
||||
|
||||
val x by O::z
|
||||
|
||||
fun box(): String = if (initialized) x else "Fail"
|
||||
+6
@@ -14463,6 +14463,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
public void testWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/withSideEffects.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("withSideEffectsFromFileClass.kt")
|
||||
public void testWithSideEffectsFromFileClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/withSideEffectsFromFileClass.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -14583,6 +14583,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
public void testWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/withSideEffects.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("withSideEffectsFromFileClass.kt")
|
||||
public void testWithSideEffectsFromFileClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/withSideEffectsFromFileClass.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+5
@@ -11797,6 +11797,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
public void testWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/withSideEffects.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withSideEffectsFromFileClass.kt")
|
||||
public void testWithSideEffectsFromFileClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/withSideEffectsFromFileClass.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/delegatedProperty/local")
|
||||
|
||||
+6
@@ -11027,6 +11027,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
public void testWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/withSideEffects.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("withSideEffectsFromFileClass.kt")
|
||||
public void testWithSideEffectsFromFileClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/withSideEffectsFromFileClass.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -11069,6 +11069,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
public void testWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/withSideEffects.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("withSideEffectsFromFileClass.kt")
|
||||
public void testWithSideEffectsFromFileClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/withSideEffectsFromFileClass.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+5
@@ -9792,6 +9792,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
public void testWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/withSideEffects.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withSideEffectsFromFileClass.kt")
|
||||
public void testWithSideEffectsFromFileClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/withSideEffectsFromFileClass.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/delegatedProperty/local")
|
||||
|
||||
+6
@@ -12029,6 +12029,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
||||
public void testWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/withSideEffects.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("withSideEffectsFromFileClass.kt")
|
||||
public void testWithSideEffectsFromFileClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/delegateToAnother/withSideEffectsFromFileClass.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
Reference in New Issue
Block a user