Use JVM IR backend in light analysis mode tests
Add some more filters on private/synthetic stuff (which doesn't matter in practice) to make full and light analysis mode dumps as similar as possible, so that all existing tests will pass for JVM IR. Unmute some tests which were failing with the old JVM backend. Tests on repeatable annotations are muted because in full analysis, annotations are wrapped into the container (e.g. `@A(1) @A(2)` -> `@A$Container(A(1), A(2))`), but they are no in the light analysis mode. So there's always going to be a difference for these tests between full and light analysis, unless we're going to change behavior of kapt, which would be a kind of a breaking change. #KT-58497 Fixed
This commit is contained in:
+27
-1
@@ -5,8 +5,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
import org.jetbrains.kotlin.checkers.CompilerTestLanguageVersionSettings
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.container.StorageComponentContainer
|
||||
import org.jetbrains.kotlin.container.useInstance
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
@@ -21,6 +23,7 @@ import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||
import org.jetbrains.kotlin.resolve.jvm.ReplaceWithSupertypeAnonymousTypeTransformer
|
||||
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
|
||||
import org.jetbrains.kotlin.resolve.jvm.extensions.PartialAnalysisHandlerExtension
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil.getAnnotationsJar
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes.*
|
||||
import org.jetbrains.org.objectweb.asm.tree.ClassNode
|
||||
@@ -40,13 +43,15 @@ abstract class AbstractLightAnalysisModeTest : CodegenTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
override val backend: TargetBackend
|
||||
get() = TargetBackend.JVM_IR
|
||||
|
||||
override fun doMultiFileTest(wholeFile: File, files: List<TestFile>) {
|
||||
for (file in files) {
|
||||
if (ignoreDirectives.any { file.content.contains(it) }) return
|
||||
}
|
||||
|
||||
val fullTxt = compileWithFullAnalysis(files)
|
||||
.replace("final enum class", "enum class")
|
||||
|
||||
val liteTxt = compileWithLightAnalysis(wholeFile, files)
|
||||
.replace("@synthetic.kotlin.jvm.GeneratedByJvmOverloads ", "")
|
||||
@@ -64,6 +69,7 @@ abstract class AbstractLightAnalysisModeTest : CodegenTestCase() {
|
||||
// Fail if this test is not under codegen/box
|
||||
assert(!relativePath.startsWith(".."))
|
||||
|
||||
configurationKind = extractConfigurationKind(files)
|
||||
val configuration = createConfiguration(
|
||||
configurationKind, getTestJdkKind(files), backend, listOf(getAnnotationsJar()), listOfNotNull(writeJavaFiles(files)), files
|
||||
)
|
||||
@@ -91,6 +97,26 @@ abstract class AbstractLightAnalysisModeTest : CodegenTestCase() {
|
||||
return BytecodeListingTextCollectingVisitor.getText(classFileFactory, ListAnalysisFilter())
|
||||
}
|
||||
|
||||
override fun updateConfiguration(configuration: CompilerConfiguration) {
|
||||
super.updateConfiguration(configuration)
|
||||
configureIrAnalysisFlag(configuration)
|
||||
}
|
||||
|
||||
// TODO: rewrite the test on the new infrastructure, so that this won't be needed.
|
||||
private fun configureIrAnalysisFlag(configuration: CompilerConfiguration) {
|
||||
val irFlag: Map<AnalysisFlag<*>, Boolean> = mapOf(JvmAnalysisFlags.useIR to backend.isIR)
|
||||
val lvs = configuration.languageVersionSettings
|
||||
if (lvs is CompilerTestLanguageVersionSettings) {
|
||||
configuration.languageVersionSettings = LanguageVersionSettingsImpl(
|
||||
lvs.languageVersion, lvs.apiVersion, lvs.analysisFlags + irFlag, lvs.extraLanguageFeatures,
|
||||
)
|
||||
} else {
|
||||
configuration.languageVersionSettings = LanguageVersionSettingsImpl(
|
||||
LanguageVersion.LATEST_STABLE, ApiVersion.LATEST_STABLE, irFlag,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private class ListAnalysisFilter : BytecodeListingTextCollectingVisitor.Filter {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun shouldWriteClass(node: ClassNode): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user