Fir2Ir: enable IR-based fake override builder

Invert the logic of IR/FIR2IR-based generators: change the CLI argument
to -Xuse-fir-fake-override-builder, test directive to
USE_FIR_BASED_FAKE_OVERRIDE_GENERATOR, etc.

The changes in test data caused by using IR fake override builder by
default are in the subsequent commit.

 #KT-61514
This commit is contained in:
Alexander Udalov
2024-02-26 16:19:04 +01:00
committed by Space Team
parent 09db7dbd22
commit f98a22e8e4
30 changed files with 72 additions and 81 deletions
@@ -7,21 +7,21 @@ package org.jetbrains.kotlin.test.backend.ir
import org.jetbrains.kotlin.test.WrappedException
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.ENABLE_IR_FAKE_OVERRIDE_GENERATION
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.ENABLE_FIR_FAKE_OVERRIDE_GENERATION
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.IGNORE_CODEGEN_WITH_FIR2IR_FAKE_OVERRIDE_GENERATION
import org.jetbrains.kotlin.test.model.AfterAnalysisChecker
import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.defaultsProvider
import org.jetbrains.kotlin.test.services.moduleStructure
class CodegenWithIrFakeOverrideGeneratorSuppressor(testServices: TestServices) : AfterAnalysisChecker(testServices) {
class CodegenWithFir2IrFakeOverrideGeneratorSuppressor(testServices: TestServices) : AfterAnalysisChecker(testServices) {
override fun suppressIfNeeded(failedAssertions: List<WrappedException>): List<WrappedException> {
return when {
!mainDirectiveEnabled -> failedAssertions
suppressDirectiveEnabled ->
if (failedAssertions.isEmpty())
listOf(
AssertionError("Looks like this test can be unmuted. Remove $IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION directive.").wrap()
AssertionError("Looks like this test can be unmuted. Remove $IGNORE_CODEGEN_WITH_FIR2IR_FAKE_OVERRIDE_GENERATION directive.").wrap()
)
else emptyList()
testServices.defaultsProvider.defaultTargetBackend
@@ -32,8 +32,8 @@ class CodegenWithIrFakeOverrideGeneratorSuppressor(testServices: TestServices) :
}
private val mainDirectiveEnabled: Boolean
get() = ENABLE_IR_FAKE_OVERRIDE_GENERATION in testServices.moduleStructure.allDirectives
get() = ENABLE_FIR_FAKE_OVERRIDE_GENERATION in testServices.moduleStructure.allDirectives
private val suppressDirectiveEnabled: Boolean
get() = IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION in testServices.moduleStructure.allDirectives
get() = IGNORE_CODEGEN_WITH_FIR2IR_FAKE_OVERRIDE_GENERATION in testServices.moduleStructure.allDirectives
}
@@ -250,16 +250,16 @@ object CodegenTestDirectives : SimpleDirectivesContainer() {
""".trimIndent()
)
val ENABLE_IR_FAKE_OVERRIDE_GENERATION by directive(
val ENABLE_FIR_FAKE_OVERRIDE_GENERATION by directive(
description = """
Enables fake-override generation in FIR2IR using IR f/o generator on JVM. KT-61514
Enables fake-override generation in FIR2IR using FIR2IR f/o generator on JVM, i.e. revert to behavior before KT-61514 was resolved
""".trimIndent()
)
// String to allow and enforce issue id. Value is not actually used.
val IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION by stringDirective(
val IGNORE_CODEGEN_WITH_FIR2IR_FAKE_OVERRIDE_GENERATION by stringDirective(
description = """
Suppresses test if $ENABLE_IR_FAKE_OVERRIDE_GENERATION directive enabled
Suppresses test if $ENABLE_FIR_FAKE_OVERRIDE_GENERATION directive enabled
""".trimIndent()
)
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.test.backend.ir.*
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.builders.configureFirHandlersStep
import org.jetbrains.kotlin.test.builders.configureIrHandlersStep
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.ENABLE_IR_FAKE_OVERRIDE_GENERATION
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.ENABLE_FIR_FAKE_OVERRIDE_GENERATION
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives.WITH_STDLIB
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.USE_PSI_CLASS_FILES_READING
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives
@@ -97,15 +97,15 @@ open class AbstractFirLightTreeBlackBoxCodegenTest : AbstractFirBlackBoxCodegenT
@FirPsiCodegenTest
open class AbstractFirPsiBlackBoxCodegenTest : AbstractFirBlackBoxCodegenTestBase(FirParser.Psi)
open class AbstractFirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTest : AbstractFirLightTreeBlackBoxCodegenTest() {
open class AbstractFirLightTreeBlackBoxCodegenWithFir2IrFakeOverrideGeneratorTest : AbstractFirLightTreeBlackBoxCodegenTest() {
override fun configure(builder: TestConfigurationBuilder) {
super.configure(builder)
with(builder) {
defaultDirectives {
+ENABLE_IR_FAKE_OVERRIDE_GENERATION
+ENABLE_FIR_FAKE_OVERRIDE_GENERATION
}
useAfterAnalysisCheckers(::CodegenWithIrFakeOverrideGeneratorSuppressor)
useAfterAnalysisCheckers(::CodegenWithFir2IrFakeOverrideGeneratorSuppressor)
}
}
}
@@ -130,9 +130,10 @@ fun createCompilerConfiguration(module: TestModule, configurators: List<Abstract
val configuration = CompilerConfiguration()
configuration[CommonConfigurationKeys.MODULE_NAME] = module.name
if (module.targetPlatform.isJvm() && CodegenTestDirectives.ENABLE_IR_FAKE_OVERRIDE_GENERATION in module.directives) {
// For non-JVM platforms, the IR-based fake override builder is enabled unconditionally; on JVM it must be enabled manually.
configuration.put(CommonConfigurationKeys.USE_IR_FAKE_OVERRIDE_BUILDER, true)
if (module.targetPlatform.isJvm() && CodegenTestDirectives.ENABLE_FIR_FAKE_OVERRIDE_GENERATION in module.directives) {
// IR-based fake override generator is enabled by default on all platforms.
// On JVM, we can also test FIR2IR-based fake override generator.
configuration.put(CommonConfigurationKeys.USE_FIR_BASED_FAKE_OVERRIDE_GENERATOR, true)
}
if (JsEnvironmentConfigurationDirectives.GENERATE_STRICT_IMPLICIT_EXPORT in module.directives) {