[FIR2IR] Implement tables merging in Fir2Ir classes and SymbolTable

- Pass dependent (usually common code) components to further FIR2IR converters
- Don't reinitialize builtin
This commit is contained in:
Ivan Kochurkin
2022-11-18 19:54:36 +01:00
committed by Space Team
parent 5d273ce839
commit f17e1314f6
20 changed files with 376 additions and 101 deletions
@@ -31693,6 +31693,30 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInMultiModule() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/multiModule"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@Test
@TestMetadata("correctParentForTypeParameter.kt")
public void testCorrectParentForTypeParameter() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/multiModule/correctParentForTypeParameter.kt");
}
@Test
@TestMetadata("enumEntryNameCall.kt")
public void testEnumEntryNameCall() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/multiModule/enumEntryNameCall.kt");
}
@Test
@TestMetadata("expectActualMultiCommon.kt")
public void testExpectActualMultiCommon() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualMultiCommon.kt");
}
@Test
@TestMetadata("expectActualSimple.kt")
public void testExpectActualSimple() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualSimple.kt");
}
}
}
@@ -32695,6 +32695,72 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
public void testAllFilesPresentInMultiModule() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/multiplatform/multiModule"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("correctParentForTypeParameter.kt")
public void testCorrectParentForTypeParameter() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/multiModule/correctParentForTypeParameter.kt");
}
@Test
@TestMetadata("enumEntryNameCall.kt")
public void testEnumEntryNameCall() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/multiModule/enumEntryNameCall.kt");
}
@Test
@TestMetadata("expectActualCallableReference.kt")
public void testExpectActualCallableReference() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualCallableReference.kt");
}
@Test
@TestMetadata("expectActualDifferentPackages.kt")
public void testExpectActualDifferentPackages() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualDifferentPackages.kt");
}
@Test
@TestMetadata("expectActualFakeOverrides.kt")
public void testExpectActualFakeOverrides() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualFakeOverrides.kt");
}
@Test
@TestMetadata("expectActualMultiCommon.kt")
public void testExpectActualMultiCommon() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualMultiCommon.kt");
}
@Test
@TestMetadata("expectActualOverloads.kt")
public void testExpectActualOverloads() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualOverloads.kt");
}
@Test
@TestMetadata("expectActualSimple.kt")
public void testExpectActualSimple() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualSimple.kt");
}
@Test
@TestMetadata("expectActualTypealias.kt")
public void testExpectActualTypealias() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/multiModule/expectActualTypealias.kt");
}
@Test
@TestMetadata("kt-51753-1.kt")
public void testKt_51753_1() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/multiModule/kt-51753-1.kt");
}
@Test
@TestMetadata("kt-51753-2.kt")
public void testKt_51753_2() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/multiModule/kt-51753-2.kt");
}
}
}
@@ -126,7 +126,8 @@ fun AbstractFirAnalyzerFacade.convertToJsIr(
Fir2IrJvmSpecialAnnotationSymbolProvider(), // TODO: replace with appropriate (probably empty) implementation
irGeneratorExtensions,
generateSignatures = false,
kotlinBuiltIns = builtIns ?: DefaultBuiltIns.Instance // TODO: consider passing externally
kotlinBuiltIns = builtIns ?: DefaultBuiltIns.Instance, // TODO: consider passing externally,
dependentComponents = emptyList()
).also {
(it.irModuleFragment.descriptor as? FirModuleDescriptor)?.let { it.allDependencyModules = dependencies }
}
@@ -68,7 +68,14 @@ class Fir2IrResultsConverter(
lateinit var mainIrPart: JvmIrCodegenFactory.JvmIrBackendInput
for ((index, firOutputPart) in inputArtifact.partsForDependsOnModules.withIndex()) {
val (irModuleFragment, components, pluginContext) = firOutputPart.firAnalyzerFacade.convertToIr(fir2IrExtensions)
val dependentComponents = mutableListOf<Fir2IrComponents>()
if (isMppSupported) {
for (dependency in firOutputPart.module.dependsOnDependencies) {
dependentComponents.add(componentsMap[dependency.moduleName]!!)
}
}
val (irModuleFragment, components, pluginContext) = firOutputPart.firAnalyzerFacade.convertToIr(fir2IrExtensions, dependentComponents)
componentsMap[firOutputPart.module.name] = components
val irPart = JvmIrCodegenFactory.JvmIrBackendInput(