diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/HandlerUtils.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/HandlerUtils.kt index e854890a70b..b6d703bb7ba 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/HandlerUtils.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/HandlerUtils.kt @@ -14,9 +14,7 @@ import org.jetbrains.kotlin.diagnostics.Severity import org.jetbrains.kotlin.diagnostics.impl.BaseDiagnosticsCollector import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory -import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.test.FirParser -import org.jetbrains.kotlin.test.backend.ir.IrBackendInput import org.jetbrains.kotlin.test.directives.DiagnosticsDirectives import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives import org.jetbrains.kotlin.test.directives.model.singleOrZeroValue @@ -28,14 +26,6 @@ import org.jetbrains.kotlin.test.services.* import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly import java.io.File -// TODO: inline this function -inline fun IrBackendInput.processAllIrModuleFragments( - module: TestModule, - processor: (irModuleFragment: IrModuleFragment, moduleName: String) -> Unit -) { - processor(irModuleFragment, module.name) -} - fun BinaryArtifactHandler<*>.reportKtDiagnostics(module: TestModule, ktDiagnosticReporter: BaseDiagnosticsCollector) { val globalMetadataInfoHandler = testServices.globalMetadataInfoHandler val firParser = module.directives.singleOrZeroValue(FirDiagnosticsDirectives.FIR_PARSER) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrInlineBodiesHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrInlineBodiesHandler.kt index eb9bf74db4d..2cb5d8e8f40 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrInlineBodiesHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrInlineBodiesHandler.kt @@ -26,10 +26,8 @@ class IrInlineBodiesHandler(testServices: TestServices) : AbstractIrHandler(test @OptIn(ObsoleteDescriptorBasedAPI::class) override fun processModule(module: TestModule, info: IrBackendInput) { - info.processAllIrModuleFragments(module) { irModule, _ -> - irModule.acceptChildrenVoid(InlineFunctionsCollector()) - irModule.acceptChildrenVoid(InlineCallBodiesCheck(firEnabled = module.frontendKind == FrontendKinds.FIR)) - } + info.irModuleFragment.acceptChildrenVoid(InlineFunctionsCollector()) + info.irModuleFragment.acceptChildrenVoid(InlineCallBodiesCheck(firEnabled = module.frontendKind == FrontendKinds.FIR)) assertions.assertTrue((info as IrBackendInput.JvmIrBackendInput).backendInput.symbolTable.descriptorExtension.allUnboundSymbols.isEmpty()) } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrInterpreterBackendHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrInterpreterBackendHandler.kt index 8ec0ef731f2..c53157a881d 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrInterpreterBackendHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrInterpreterBackendHandler.kt @@ -37,11 +37,9 @@ open class IrInterpreterBackendHandler(testServices: TestServices) : AbstractIrH override fun processAfterAllModules(someAssertionWasFailed: Boolean) {} override fun processModule(module: TestModule, info: IrBackendInput) { - info.processAllIrModuleFragments(module) { moduleFragment, _ -> - val evaluator = Evaluator(IrInterpreter(moduleFragment.irBuiltins), globalMetadataInfoHandler) - for ((irFile, testFile) in matchIrFileWithTestFile(moduleFragment, module)) { - evaluator.evaluate(irFile, testFile) - } + val evaluator = Evaluator(IrInterpreter(info.irModuleFragment.irBuiltins), globalMetadataInfoHandler) + for ((irFile, testFile) in matchIrFileWithTestFile(info.irModuleFragment, module)) { + evaluator.evaluate(irFile, testFile) } } } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrPrettyKotlinDumpHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrPrettyKotlinDumpHandler.kt index 03b833de8a4..931563ac343 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrPrettyKotlinDumpHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrPrettyKotlinDumpHandler.kt @@ -72,16 +72,14 @@ internal fun dumpModuleKotlinLike( multiModuleInfoDumper: MultiModuleInfoDumper, options: KotlinLikeDumpOptions, ) { - info.processAllIrModuleFragments(module) { irModuleFragment, moduleName -> - val irFiles = irModuleFragment.files - val builder = multiModuleInfoDumper.builderForModule(moduleName) - val filteredIrFiles = irFiles.groupWithTestFiles(module).filterNot { (testFile, _) -> - testFile?.let { EXTERNAL_FILE in it.directives || it.isAdditional } ?: false - }.map { it.second } - val printFileName = filteredIrFiles.size > 1 || allModules.size > 1 - val modifiedOptions = options.copy(printFileName = printFileName) - for (irFile in filteredIrFiles) { - builder.append(irFile.dumpKotlinLike(modifiedOptions)) - } + val irFiles = info.irModuleFragment.files + val builder = multiModuleInfoDumper.builderForModule(module.name) + val filteredIrFiles = irFiles.groupWithTestFiles(module).filterNot { (testFile, _) -> + testFile?.let { EXTERNAL_FILE in it.directives || it.isAdditional } ?: false + }.map { it.second } + val printFileName = filteredIrFiles.size > 1 || allModules.size > 1 + val modifiedOptions = options.copy(printFileName = printFileName) + for (irFile in filteredIrFiles) { + builder.append(irFile.dumpKotlinLike(modifiedOptions)) } } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrSourceRangesDumpHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrSourceRangesDumpHandler.kt index 97ca2aafd93..c67c5edbbf8 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrSourceRangesDumpHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrSourceRangesDumpHandler.kt @@ -42,12 +42,9 @@ class IrSourceRangesDumpHandler( override fun processModule(module: TestModule, info: IrBackendInput) { if (CodegenTestDirectives.DUMP_SOURCE_RANGES_IR !in module.directives) return - info.processAllIrModuleFragments(module) { irModuleFragment, moduleName -> - val builder = baseDumper.builderForModule(moduleName) - - for (irFile in irModuleFragment.files) { - builder.append(irFile.dumpWithSourceLocations(irFile.fileEntry)) - } + val builder = baseDumper.builderForModule(module.name) + for (irFile in info.irModuleFragment.files) { + builder.append(irFile.dumpWithSourceLocations(irFile.fileEntry)) } } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTextDumpHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTextDumpHandler.kt index c99c1c7d8c3..66a3a3225da 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTextDumpHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTextDumpHandler.kt @@ -76,18 +76,15 @@ class IrTextDumpHandler( printTypeAbbreviations = false, ) - info.processAllIrModuleFragments(module) { irModuleFragment, moduleName -> - val builder = baseDumper.builderForModule(moduleName) - val testFileToIrFile = irModuleFragment.files.groupWithTestFiles(module) - - for ((testFile, irFile) in testFileToIrFile) { - if (testFile?.directives?.contains(EXTERNAL_FILE) == true) continue - var actualDump = irFile.dumpTreesFromLineNumber(lineNumber = 0, dumpOptions) - if (actualDump.isEmpty()) { - actualDump = irFile.dumpTreesFromLineNumber(lineNumber = UNDEFINED_OFFSET, dumpOptions) - } - builder.append(actualDump) + val builder = baseDumper.builderForModule(module.name) + val testFileToIrFile = info.irModuleFragment.files.groupWithTestFiles(module) + for ((testFile, irFile) in testFileToIrFile) { + if (testFile?.directives?.contains(EXTERNAL_FILE) == true) continue + var actualDump = irFile.dumpTreesFromLineNumber(lineNumber = 0, dumpOptions) + if (actualDump.isEmpty()) { + actualDump = irFile.dumpTreesFromLineNumber(lineNumber = UNDEFINED_OFFSET, dumpOptions) } + builder.append(actualDump) } compareDumpsOfExternalClasses(module, info) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTreeVerifierHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTreeVerifierHandler.kt index 4dabbcf4d46..94fdf5ead68 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTreeVerifierHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTreeVerifierHandler.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.test.backend.handlers import org.jetbrains.kotlin.ir.IrVerifier +import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.util.DumpIrTreeOptions import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols import org.jetbrains.kotlin.ir.util.dumpTreesFromLineNumber @@ -29,20 +30,18 @@ class IrTreeVerifierHandler( override fun processModule(module: TestModule, info: IrBackendInput) { if (CodegenTestDirectives.DUMP_IR !in module.directives) return - info.processAllIrModuleFragments(module) { irModuleFragment, _ -> - val irFiles = irModuleFragment.files - val testFileToIrFile = irFiles.groupWithTestFiles(module) - for ((testFile, irFile) in testFileToIrFile) { - if (testFile?.directives?.contains(EXTERNAL_FILE) == true) continue + val irFiles = info.irModuleFragment.files + val testFileToIrFile = irFiles.groupWithTestFiles(module) + for ((testFile, irFile) in testFileToIrFile) { + if (testFile?.directives?.contains(EXTERNAL_FILE) == true) continue - IrVerifier(assertions, module.frontendKind == FrontendKinds.FIR).verifyWithAssert(irFile) + IrVerifier(assertions, module.frontendKind == FrontendKinds.FIR).verifyWithAssert(irFile) - val actualDump = irFile.dumpTreesFromLineNumber(lineNumber = 0, DumpIrTreeOptions(normalizeNames = true)) + val actualDump = irFile.dumpTreesFromLineNumber(lineNumber = 0, DumpIrTreeOptions(normalizeNames = true)) - val irFileCopy = irFile.deepCopyWithSymbols() - val dumpOfCopy = irFileCopy.dumpTreesFromLineNumber(lineNumber = 0, DumpIrTreeOptions(normalizeNames = true)) - assertions.assertEquals(actualDump, dumpOfCopy) { "IR dump mismatch after deep copy with symbols" } - } + val irFileCopy = irFile.deepCopyWithSymbols() + val dumpOfCopy = irFileCopy.dumpTreesFromLineNumber(lineNumber = 0, DumpIrTreeOptions(normalizeNames = true)) + assertions.assertEquals(actualDump, dumpOfCopy) { "IR dump mismatch after deep copy with symbols" } } }