[LL FIR] AbstractCompilerBasedTestForFir: convert receiver to parameter

to allow using super call from implementations

^KT-66232
This commit is contained in:
Dmitrii Gridin
2024-03-01 15:36:05 +01:00
committed by Space Team
parent 4b5eac7816
commit d6b3f6f352
8 changed files with 82 additions and 60 deletions
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -19,29 +19,34 @@ import org.jetbrains.kotlin.test.runners.configurationForClassicAndFirTestsAlong
import org.jetbrains.kotlin.utils.bind import org.jetbrains.kotlin.utils.bind
abstract class AbstractLLFirNativeTestBase : AbstractCompilerBasedTestForFir() { abstract class AbstractLLFirNativeTestBase : AbstractCompilerBasedTestForFir() {
override fun configureTest(builder: TestConfigurationBuilder) {
with(builder) {
globalDefaults {
targetPlatform = NativePlatforms.unspecifiedNativePlatform
}
protected fun TestConfigurationBuilder.baseConfiguration() { baseFirNativeDiagnosticTestConfiguration()
globalDefaults { configurationForClassicAndFirTestsAlongside(::ReversedFirIdenticalChecker)
targetPlatform = NativePlatforms.unspecifiedNativePlatform
} }
baseFirNativeDiagnosticTestConfiguration()
configurationForClassicAndFirTestsAlongside(::ReversedFirIdenticalChecker)
} }
} }
abstract class AbstractLLFirNativeTest : AbstractLLFirNativeTestBase() { abstract class AbstractLLFirNativeTest : AbstractLLFirNativeTestBase() {
override fun TestConfigurationBuilder.configureTest() { override fun configureTest(builder: TestConfigurationBuilder) {
baseNativeDiagnosticTestConfiguration(::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithoutPreresolve)) with(builder) {
baseConfiguration() baseNativeDiagnosticTestConfiguration(::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithoutPreresolve))
useAfterAnalysisCheckers(::LLFirOnlyNonReversedTestSuppressor) super.configureTest(builder)
useAfterAnalysisCheckers(::LLFirOnlyNonReversedTestSuppressor)
}
} }
} }
abstract class AbstractLLFirReversedNativeTest : AbstractLLFirNativeTestBase() { abstract class AbstractLLFirReversedNativeTest : AbstractLLFirNativeTestBase() {
override fun TestConfigurationBuilder.configureTest() { override fun configureTest(builder: TestConfigurationBuilder) {
baseNativeDiagnosticTestConfiguration(::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithPreresolveInReversedOrder)) with(builder) {
baseConfiguration() baseNativeDiagnosticTestConfiguration(::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithPreresolveInReversedOrder))
useAfterAnalysisCheckers(::LLFirOnlyReversedTestSuppressor) super.configureTest(builder)
useAfterAnalysisCheckers(::LLFirOnlyReversedTestSuppressor)
}
} }
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -49,7 +49,7 @@ abstract class AbstractCompilerBasedTestForFir : AbstractCompilerBasedTest() {
} }
FirLowLevelCompilerBasedTestConfigurator.configureTest(this, disposable) FirLowLevelCompilerBasedTestConfigurator.configureTest(this, disposable)
configureTest() configureTest(this)
defaultConfiguration(this) defaultConfiguration(this)
registerAnalysisApiBaseTestServices(disposable, FirLowLevelCompilerBasedTestConfigurator) registerAnalysisApiBaseTestServices(disposable, FirLowLevelCompilerBasedTestConfigurator)
useDirectives(SealedClassesInheritorsCalculatorPreAnalysisHandler.Directives) useDirectives(SealedClassesInheritorsCalculatorPreAnalysisHandler.Directives)
@@ -72,7 +72,7 @@ abstract class AbstractCompilerBasedTestForFir : AbstractCompilerBasedTest() {
useAfterAnalysisCheckers(::LLFirTestSuppressor) useAfterAnalysisCheckers(::LLFirTestSuppressor)
} }
open fun TestConfigurationBuilder.configureTest() {} abstract fun configureTest(builder: TestConfigurationBuilder)
inner class LowLevelFirFrontendFacade( inner class LowLevelFirFrontendFacade(
testServices: TestServices, testServices: TestServices,
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -20,13 +20,16 @@ import org.jetbrains.kotlin.test.services.moduleStructure
import org.jetbrains.kotlin.utils.bind import org.jetbrains.kotlin.utils.bind
abstract class AbstractDiagnosticCompilerTestDataTest : AbstractCompilerBasedTestForFir() { abstract class AbstractDiagnosticCompilerTestDataTest : AbstractCompilerBasedTestForFir() {
override fun TestConfigurationBuilder.configureTest() { override fun configureTest(builder: TestConfigurationBuilder) {
baseFirDiagnosticTestConfiguration( with(builder) {
frontendFacade = ::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithoutPreresolve), baseFirDiagnosticTestConfiguration(
testDataConsistencyHandler = ::ReversedFirIdenticalChecker, frontendFacade = ::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithoutPreresolve),
) testDataConsistencyHandler = ::ReversedFirIdenticalChecker,
useAfterAnalysisCheckers(::ContractViolationSuppressor) )
useAfterAnalysisCheckers(::LLFirOnlyNonReversedTestSuppressor)
useAfterAnalysisCheckers(::ContractViolationSuppressor)
useAfterAnalysisCheckers(::LLFirOnlyNonReversedTestSuppressor)
}
} }
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -11,9 +11,11 @@ import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.utils.bind import org.jetbrains.kotlin.utils.bind
abstract class AbstractLLFirBlackBoxCodegenBasedTest : AbstractLLFirBlackBoxCodegenBasedTestBase() { abstract class AbstractLLFirBlackBoxCodegenBasedTest : AbstractLLFirBlackBoxCodegenBasedTestBase() {
override fun TestConfigurationBuilder.configureTest() { override fun configureTest(builder: TestConfigurationBuilder) {
facadeStep(::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithoutPreresolve)) with(builder) {
baseConfiguration() facadeStep(::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithoutPreresolve))
useAfterAnalysisCheckers(::LLFirOnlyNonReversedTestSuppressor) baseConfiguration()
useAfterAnalysisCheckers(::LLFirOnlyNonReversedTestSuppressor)
}
} }
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -13,9 +13,14 @@ import org.jetbrains.kotlin.test.runners.baseFirSpecDiagnosticTestConfiguration
import org.jetbrains.kotlin.utils.bind import org.jetbrains.kotlin.utils.bind
abstract class AbstractLLFirDiagnosticCompilerTestDataSpecTest : AbstractCompilerBasedTestForFir() { abstract class AbstractLLFirDiagnosticCompilerTestDataSpecTest : AbstractCompilerBasedTestForFir() {
override fun TestConfigurationBuilder.configureTest() { override fun configureTest(builder: TestConfigurationBuilder) {
baseFirDiagnosticTestConfiguration(frontendFacade = ::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithoutPreresolve)) with(builder) {
baseFirSpecDiagnosticTestConfigurationForIde() baseFirDiagnosticTestConfiguration(
frontendFacade = ::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithoutPreresolve),
)
baseFirSpecDiagnosticTestConfigurationForIde()
}
} }
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -13,13 +13,16 @@ import org.jetbrains.kotlin.test.runners.baseFirDiagnosticTestConfiguration
import org.jetbrains.kotlin.utils.bind import org.jetbrains.kotlin.utils.bind
abstract class AbstractLLFirPreresolvedReversedDiagnosticCompilerTestDataSpecTest : AbstractCompilerBasedTestForFir() { abstract class AbstractLLFirPreresolvedReversedDiagnosticCompilerTestDataSpecTest : AbstractCompilerBasedTestForFir() {
override fun TestConfigurationBuilder.configureTest() { override fun configureTest(builder: TestConfigurationBuilder) {
baseFirDiagnosticTestConfiguration( with(builder) {
frontendFacade = ::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithPreresolveInReversedOrder) baseFirDiagnosticTestConfiguration(
) frontendFacade = ::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithPreresolveInReversedOrder),
baseFirSpecDiagnosticTestConfigurationForIde() )
useAfterAnalysisCheckers(::LLFirOnlyReversedTestSuppressor)
useMetaTestConfigurators(::ReversedDiagnosticsConfigurator) baseFirSpecDiagnosticTestConfigurationForIde()
useAfterAnalysisCheckers(::ReversedFirIdenticalChecker) useAfterAnalysisCheckers(::LLFirOnlyReversedTestSuppressor)
useMetaTestConfigurators(::ReversedDiagnosticsConfigurator)
useAfterAnalysisCheckers(::ReversedFirIdenticalChecker)
}
} }
} }
@@ -1,33 +1,35 @@
/* /*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
package org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostic.compiler.based package org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostic.compiler.based
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirOnlyReversedTestSuppressor import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirOnlyReversedTestSuppressor
import java.io.File
import org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based.AbstractCompilerBasedTestForFir import org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based.AbstractCompilerBasedTestForFir
import org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostic.compiler.based.facades.LLFirAnalyzerFacadeFactoryWithPreresolveInReversedOrder import org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostic.compiler.based.facades.LLFirAnalyzerFacadeFactoryWithPreresolveInReversedOrder
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.runners.baseFirDiagnosticTestConfiguration
import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.frontend.fir.handlers.AbstractFirIdenticalChecker import org.jetbrains.kotlin.test.frontend.fir.handlers.AbstractFirIdenticalChecker
import org.jetbrains.kotlin.test.runners.baseFirDiagnosticTestConfiguration
import org.jetbrains.kotlin.test.services.MetaTestConfigurator import org.jetbrains.kotlin.test.services.MetaTestConfigurator
import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.assertions
import org.jetbrains.kotlin.test.utils.firTestDataFile import org.jetbrains.kotlin.test.utils.firTestDataFile
import org.jetbrains.kotlin.test.utils.llFirTestDataFile import org.jetbrains.kotlin.test.utils.llFirTestDataFile
import org.jetbrains.kotlin.utils.bind import org.jetbrains.kotlin.utils.bind
import java.io.File
abstract class AbstractLLFirPreresolvedReversedDiagnosticCompilerTestDataTest : AbstractCompilerBasedTestForFir() { abstract class AbstractLLFirPreresolvedReversedDiagnosticCompilerTestDataTest : AbstractCompilerBasedTestForFir() {
override fun TestConfigurationBuilder.configureTest() { override fun configureTest(builder: TestConfigurationBuilder) {
baseFirDiagnosticTestConfiguration( with(builder) {
frontendFacade = ::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithPreresolveInReversedOrder), baseFirDiagnosticTestConfiguration(
testDataConsistencyHandler = ::ReversedFirIdenticalChecker, frontendFacade = ::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithPreresolveInReversedOrder),
) testDataConsistencyHandler = ::ReversedFirIdenticalChecker,
)
useAfterAnalysisCheckers(::LLFirOnlyReversedTestSuppressor) useAfterAnalysisCheckers(::LLFirOnlyReversedTestSuppressor)
useMetaTestConfigurators(::ReversedDiagnosticsConfigurator) useMetaTestConfigurators(::ReversedDiagnosticsConfigurator)
}
} }
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -11,9 +11,11 @@ import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.utils.bind import org.jetbrains.kotlin.utils.bind
abstract class AbstractLLFirReversedBlackBoxCodegenBasedTest : AbstractLLFirBlackBoxCodegenBasedTestBase() { abstract class AbstractLLFirReversedBlackBoxCodegenBasedTest : AbstractLLFirBlackBoxCodegenBasedTestBase() {
override fun TestConfigurationBuilder.configureTest() { override fun configureTest(builder: TestConfigurationBuilder) {
facadeStep(::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithPreresolveInReversedOrder)) with(builder) {
baseConfiguration() facadeStep(::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithPreresolveInReversedOrder))
useAfterAnalysisCheckers(::LLFirOnlyReversedTestSuppressor) baseConfiguration()
useAfterAnalysisCheckers(::LLFirOnlyReversedTestSuppressor)
}
} }
} }