[IR] Fix file modules after actualization

When files from different IrModules are merged in IrActualizer
their IrModule link was not updated. This led to assuming them
as different modules, and incorrect internal visibility handling.

^KT-62623
This commit is contained in:
Pavel Kunyavskiy
2023-10-16 17:17:00 +02:00
committed by Space Team
parent ad5831acc6
commit da488f513f
19 changed files with 151 additions and 1 deletions
@@ -34116,6 +34116,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClassJVM.kt");
}
@Test
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@Test
@TestMetadata("javaMethodWithTypeParameter.kt")
public void testJavaMethodWithTypeParameter() throws Exception {
@@ -34116,6 +34116,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClassJVM.kt");
}
@Test
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@Test
@TestMetadata("javaMethodWithTypeParameter.kt")
public void testJavaMethodWithTypeParameter() throws Exception {
@@ -34116,6 +34116,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClassJVM.kt");
}
@Test
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@Test
@TestMetadata("javaMethodWithTypeParameter.kt")
public void testJavaMethodWithTypeParameter() throws Exception {
@@ -119,7 +119,9 @@ object IrActualizer {
}
private fun mergeIrFragments(mainFragment: IrModuleFragment, dependentFragments: List<IrModuleFragment>) {
mainFragment.files.addAll(0, dependentFragments.flatMap { it.files })
val newFiles = dependentFragments.flatMap { it.files }
for (file in newFiles) file.module = mainFragment
mainFragment.files.addAll(0, newFiles)
}
}
@@ -0,0 +1,47 @@
// LANGUAGE: +MultiPlatformProjects
// It accidentially passes K1 JVM while not intended to do so.
// IGNORE_BACKEND_K1: JS, JS_IR, JS_IR_ES6, WASM, NATIVE
// MODULE: common
// FILE: common.kt
open class A {
open internal fun foo() = "A"
}
open class B {
open internal fun foo() = "B"
}
// MODULE: middle()()(common)
// FILE: middle.kt
class AChild : A() {
override public fun foo() = "AChild"
}
open class C {
open internal fun foo() = "C"
}
// MODULE: main()()(middle)
// FILE: main.kt
class BChild : B() {
override public fun foo() = "BChild"
}
class CChild : C() {
override public fun foo() = "CChild"
}
fun box() : String {
val a: A = AChild()
val b: B = BChild()
val c: C = CChild()
if (a.foo() != "AChild") return "Fail 1"
if (b.foo() != "BChild") return "Fail 2"
if (c.foo() != "CChild") return "Fail 3"
return "OK"
}
@@ -32394,6 +32394,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClassJVM.kt");
}
@Test
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -34116,6 +34116,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClassJVM.kt");
}
@Test
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@Test
@TestMetadata("javaMethodWithTypeParameter.kt")
public void testJavaMethodWithTypeParameter() throws Exception {
@@ -34116,6 +34116,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClassJVM.kt");
}
@Test
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@Test
@TestMetadata("javaMethodWithTypeParameter.kt")
public void testJavaMethodWithTypeParameter() throws Exception {
@@ -29071,6 +29071,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClassJVM.kt");
}
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@TestMetadata("javaMethodWithTypeParameter.kt")
public void testJavaMethodWithTypeParameter() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/javaMethodWithTypeParameter.kt");
@@ -23820,6 +23820,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClass.kt");
}
@Test
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -23820,6 +23820,12 @@ public class FirJsES6CodegenBoxTestGenerated extends AbstractFirJsES6CodegenBoxT
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClass.kt");
}
@Test
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -23820,6 +23820,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClass.kt");
}
@Test
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -23820,6 +23820,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClass.kt");
}
@Test
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -26789,6 +26789,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClass.kt");
}
@Test
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -27405,6 +27405,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClass.kt");
}
@Test
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -26482,6 +26482,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClass.kt");
}
@Test
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -26790,6 +26790,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClass.kt");
}
@Test
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -23568,6 +23568,12 @@ public class FirWasmCodegenBoxTestGenerated extends AbstractFirWasmCodegenBoxTes
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClass.kt");
}
@Test
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -23568,6 +23568,12 @@ public class K1WasmCodegenBoxTestGenerated extends AbstractK1WasmCodegenBoxTest
runTest("compiler/testData/codegen/box/multiplatform/k2/expectValInInlineClass.kt");
}
@Test
@TestMetadata("internalOverride.kt")
public void testInternalOverride() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/internalOverride.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")