[K/JS, K/Wasm, K/Native] Process anonymous initializers inside classes as a part of their primary constructors ^KT-61929 Fixed
This commit is contained in:
+6
@@ -6736,6 +6736,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
+6
@@ -6736,6 +6736,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
+6
@@ -6677,6 +6677,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
+6
@@ -6677,6 +6677,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
+6
@@ -6677,6 +6677,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
+8
-2
@@ -585,8 +585,14 @@ class LocalDeclarationsLowering(
|
|||||||
rewriteFunctionBody(it.declaration, it)
|
rewriteFunctionBody(it.declaration, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
localClassConstructors.values.forEach {
|
localClassConstructors.values.forEach { constructorContext ->
|
||||||
rewriteFunctionBody(it.declaration, it)
|
rewriteFunctionBody(constructorContext.declaration, constructorContext)
|
||||||
|
|
||||||
|
if (!constructorContext.declaration.isPrimary) return@forEach
|
||||||
|
|
||||||
|
constructorContext.declaration.constructedClass.declarations
|
||||||
|
.filterIsInstance<IrAnonymousInitializer>()
|
||||||
|
.forEach { rewriteFunctionBody(it, constructorContext) }
|
||||||
}
|
}
|
||||||
|
|
||||||
localClasses.values.forEach {
|
localClasses.values.forEach {
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
// KT-61929
|
||||||
|
// WITH_SDTLIB
|
||||||
|
// EXPECTED_REACHABLE_NODES: 1301
|
||||||
|
package foo
|
||||||
|
|
||||||
|
fun doSomething(lambda: () -> Unit) { lambda() }
|
||||||
|
|
||||||
|
class CompilerBug(result: String) {
|
||||||
|
var result: String = "Failed"
|
||||||
|
|
||||||
|
init {
|
||||||
|
run {
|
||||||
|
object {
|
||||||
|
init {
|
||||||
|
doSomething { completed(result) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun completed(value: String) {
|
||||||
|
this.result = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return CompilerBug("OK").result
|
||||||
|
}
|
||||||
+6
@@ -6443,6 +6443,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
+6
@@ -6677,6 +6677,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
+6
@@ -6677,6 +6677,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
+5
@@ -5830,6 +5830,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/classes/outerThis.kt");
|
runTest("compiler/testData/codegen/box/classes/outerThis.kt");
|
||||||
|
|||||||
+6
@@ -4901,6 +4901,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
Generated
+6
@@ -4901,6 +4901,12 @@ public class FirJsES6CodegenBoxTestGenerated extends AbstractFirJsES6CodegenBoxT
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
+6
@@ -4901,6 +4901,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
+6
@@ -4901,6 +4901,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
+6
@@ -5056,6 +5056,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
+6
@@ -5170,6 +5170,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
+6
@@ -4942,6 +4942,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
+6
@@ -5057,6 +5057,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
Generated
+6
@@ -4883,6 +4883,12 @@ public class FirWasmCodegenBoxTestGenerated extends AbstractFirWasmCodegenBoxTes
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
Generated
+6
@@ -4883,6 +4883,12 @@ public class K1WasmCodegenBoxTestGenerated extends AbstractK1WasmCodegenBoxTest
|
|||||||
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
runTest("compiler/testData/codegen/box/classes/namedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedInitBlocksWithLambda.kt")
|
||||||
|
public void testNestedInitBlocksWithLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/nestedInitBlocksWithLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("outerThis.kt")
|
@TestMetadata("outerThis.kt")
|
||||||
public void testOuterThis() throws Exception {
|
public void testOuterThis() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user