diff --git a/compiler/testData/codegen/boxInline/delegatedProperty/kt48498.kt b/compiler/testData/codegen/boxInline/delegatedProperty/kt48498.kt index ee801c9a74f..5a2d2b81d29 100644 --- a/compiler/testData/codegen/boxInline/delegatedProperty/kt48498.kt +++ b/compiler/testData/codegen/boxInline/delegatedProperty/kt48498.kt @@ -1,3 +1,4 @@ +// IGNORE_INLINER_K2: IR // FILE: 1.kt package x diff --git a/compiler/testData/codegen/boxInline/delegatedProperty/local.kt b/compiler/testData/codegen/boxInline/delegatedProperty/local.kt index 36fc9fc367e..2f5647ca89f 100644 --- a/compiler/testData/codegen/boxInline/delegatedProperty/local.kt +++ b/compiler/testData/codegen/boxInline/delegatedProperty/local.kt @@ -1,3 +1,4 @@ +// IGNORE_INLINER_K2: IR // FILE: 1.kt package test diff --git a/compiler/testData/codegen/boxInline/delegatedProperty/localDeclaredInLambda.kt b/compiler/testData/codegen/boxInline/delegatedProperty/localDeclaredInLambda.kt index f5b26d2fcc1..b9e9ffc73c1 100644 --- a/compiler/testData/codegen/boxInline/delegatedProperty/localDeclaredInLambda.kt +++ b/compiler/testData/codegen/boxInline/delegatedProperty/localDeclaredInLambda.kt @@ -1,3 +1,4 @@ +// IGNORE_INLINER_K2: IR // IGNORE_BACKEND_MULTI_MODULE: JVM, JVM_MULTI_MODULE_IR_AGAINST_OLD // FILE: test.kt package test diff --git a/compiler/testData/codegen/boxInline/delegatedProperty/localInAnonymousObject.kt b/compiler/testData/codegen/boxInline/delegatedProperty/localInAnonymousObject.kt index c098619f778..539655ea862 100644 --- a/compiler/testData/codegen/boxInline/delegatedProperty/localInAnonymousObject.kt +++ b/compiler/testData/codegen/boxInline/delegatedProperty/localInAnonymousObject.kt @@ -1,3 +1,4 @@ +// IGNORE_INLINER_K2: IR // FILE: 1.kt package test diff --git a/compiler/testData/codegen/boxInline/delegatedProperty/localInLambda.kt b/compiler/testData/codegen/boxInline/delegatedProperty/localInLambda.kt index 851a60fab73..a37682be7e2 100644 --- a/compiler/testData/codegen/boxInline/delegatedProperty/localInLambda.kt +++ b/compiler/testData/codegen/boxInline/delegatedProperty/localInLambda.kt @@ -1,3 +1,4 @@ +// IGNORE_INLINER_K2: IR // FILE: 1.kt package test diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/BlackBoxInlinerCodegenSuppressor.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/BlackBoxInlinerCodegenSuppressor.kt index e91ede85b11..b254fb64acf 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/BlackBoxInlinerCodegenSuppressor.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/BlackBoxInlinerCodegenSuppressor.kt @@ -9,8 +9,11 @@ import org.jetbrains.kotlin.test.WrappedException import org.jetbrains.kotlin.test.directives.CodegenTestDirectives import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives import org.jetbrains.kotlin.test.directives.model.DirectivesContainer +import org.jetbrains.kotlin.test.directives.model.ValueDirective import org.jetbrains.kotlin.test.model.AfterAnalysisChecker +import org.jetbrains.kotlin.test.model.FrontendKinds import org.jetbrains.kotlin.test.services.TestServices +import org.jetbrains.kotlin.test.services.defaultsProvider import org.jetbrains.kotlin.test.services.moduleStructure enum class TargetInliner { @@ -22,19 +25,40 @@ class BlackBoxInlinerCodegenSuppressor(testServices: TestServices) : AfterAnalys get() = listOf(CodegenTestDirectives) override fun suppressIfNeeded(failedAssertions: List): List { - val ignoreDirectives = testServices.moduleStructure.allDirectives[CodegenTestDirectives.IGNORE_INLINER] - if (ignoreDirectives.size > 1) { - throw IllegalArgumentException("Directive should contain IGNORE_INLINER only one value") - } + val targetFrontend = testServices.defaultsProvider.defaultFrontend - val ignoreDirective = ignoreDirectives.singleOrNull() ?: return failedAssertions - val enabledIrInliner = LanguageSettingsDirectives.ENABLE_JVM_IR_INLINER in testServices.moduleStructure.allDirectives - val unmuteError = listOf(AssertionError("Looks like this test can be unmuted. Please remove IGNORE_INLINER directive.").wrap()) + val commonResult = suppressForTargetFrontend(failedAssertions, CodegenTestDirectives.IGNORE_INLINER) + if (commonResult != null) return commonResult - return when { - ignoreDirective == TargetInliner.IR && enabledIrInliner -> if (failedAssertions.isNotEmpty()) emptyList() else unmuteError - ignoreDirective == TargetInliner.BYTECODE && !enabledIrInliner -> if (failedAssertions.isNotEmpty()) emptyList() else unmuteError + return when (targetFrontend) { + FrontendKinds.ClassicFrontend -> { + suppressForTargetFrontend(failedAssertions, CodegenTestDirectives.IGNORE_INLINER_K1) ?: failedAssertions + } + FrontendKinds.FIR -> { + suppressForTargetFrontend(failedAssertions, CodegenTestDirectives.IGNORE_INLINER_K2) ?: failedAssertions + } else -> failedAssertions } } + + private fun suppressForTargetFrontend( + failedAssertions: List, + directive: ValueDirective + ): List? { + val directiveName = directive.name + val ignoreDirectives = testServices.moduleStructure.allDirectives[directive] + if (ignoreDirectives.size > 1) { + throw IllegalArgumentException("Directive $directiveName should contains only one value") + } + + val ignoreDirective = ignoreDirectives.singleOrNull() + val enabledIrInliner = LanguageSettingsDirectives.ENABLE_JVM_IR_INLINER in testServices.moduleStructure.allDirectives + val unmuteError = listOf(AssertionError("Looks like this test can be unmuted. Please remove $directiveName directive.").wrap()) + + if (ignoreDirective == TargetInliner.IR && enabledIrInliner || ignoreDirective == TargetInliner.BYTECODE && !enabledIrInliner) { + return if (failedAssertions.isNotEmpty()) emptyList() else unmuteError + } + + return null + } } \ No newline at end of file diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt index 9a387a20b84..d2e3aa444a7 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt @@ -51,7 +51,17 @@ object CodegenTestDirectives : SimpleDirectivesContainer() { ) val IGNORE_INLINER by enumDirective( - description = "Ignore failures of tests with given inliner", + description = "Ignore failures of tests with given inliner for all frontend kinds", + applicability = Global + ) + + val IGNORE_INLINER_K1 by enumDirective( + description = "Ignore failures of tests with given inliner for K1 compiler", + applicability = Global + ) + + val IGNORE_INLINER_K2 by enumDirective( + description = "Ignore failures of tests with given inliner for K2 compiler", applicability = Global )