Kapt: remove support for old JVM backend
#KT-64680 Fixed
This commit is contained in:
committed by
Space Team
parent
c251eb19a6
commit
a9f85d75f4
@@ -129,7 +129,6 @@ enum class KaptFlag(val description: String, val defaultValue: Boolean = false)
|
||||
INCREMENTAL_APT("Incremental annotation processing (apt mode)"),
|
||||
STRIP_METADATA("Strip @Metadata annotations from stubs"),
|
||||
KEEP_KDOC_COMMENTS_IN_STUBS("Keep KDoc comments in stubs", defaultValue = true),
|
||||
USE_JVM_IR("Use JVM IR backend", defaultValue = true),
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -214,13 +214,6 @@ enum class KaptCliOption(
|
||||
"Keep KDoc comments in stubs"
|
||||
),
|
||||
|
||||
USE_JVM_IR(
|
||||
"useJvmIr",
|
||||
"true | false",
|
||||
"Use JVM IR backend",
|
||||
cliToolOption = CliToolOption("-Kapt-use-jvm-ir", FLAG)
|
||||
),
|
||||
|
||||
USE_K2(
|
||||
"useK2",
|
||||
"true | false",
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.cli.common.messages.OutputMessageUtil
|
||||
import org.jetbrains.kotlin.cli.common.output.writeAll
|
||||
import org.jetbrains.kotlin.codegen.ClassBuilderMode
|
||||
import org.jetbrains.kotlin.codegen.DefaultCodegenFactory
|
||||
import org.jetbrains.kotlin.codegen.KotlinCodegenFacade
|
||||
import org.jetbrains.kotlin.codegen.OriginCollectingClassBuilderFactory
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
@@ -246,19 +245,15 @@ abstract class AbstractKapt3Extension(
|
||||
type = "java-production"
|
||||
)
|
||||
|
||||
val isIrBackend = options.flags[KaptFlag.USE_JVM_IR]
|
||||
val generationState = GenerationState.Builder(project, builderFactory, module, bindingContext, configuration)
|
||||
.targetId(targetId)
|
||||
.isIrBackend(isIrBackend)
|
||||
.build()
|
||||
|
||||
val (classFilesCompilationTime) = measureTimeMillis {
|
||||
KotlinCodegenFacade.compileCorrectFiles(
|
||||
files,
|
||||
generationState,
|
||||
if (isIrBackend)
|
||||
JvmIrCodegenFactory(configuration, configuration[CLIConfigurationKeys.PHASE_CONFIG])
|
||||
else DefaultCodegenFactory
|
||||
JvmIrCodegenFactory(configuration, configuration[CLIConfigurationKeys.PHASE_CONFIG])
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,6 @@ class Kapt3CommandLineProcessor : CommandLineProcessor {
|
||||
STRICT_MODE_OPTION -> setFlag(KaptFlag.STRICT, value)
|
||||
STRIP_METADATA_OPTION -> setFlag(KaptFlag.STRIP_METADATA, value)
|
||||
KEEP_KDOC_COMMENTS_IN_STUBS -> setFlag(KaptFlag.KEEP_KDOC_COMMENTS_IN_STUBS, value)
|
||||
USE_JVM_IR -> setFlag(KaptFlag.USE_JVM_IR, value)
|
||||
USE_K2 -> {}
|
||||
|
||||
SHOW_PROCESSOR_STATS -> setFlag(KaptFlag.SHOW_PROCESSOR_STATS, value)
|
||||
|
||||
+2
-8
@@ -123,8 +123,6 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
|
||||
private val mutableBindings = mutableMapOf<String, KaptJavaFileObject>()
|
||||
|
||||
private val isIrBackend = kaptContext.generationState.isIrBackend
|
||||
|
||||
val bindings: Map<String, KaptJavaFileObject>
|
||||
get() = mutableBindings
|
||||
|
||||
@@ -684,15 +682,11 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
val origin = kaptContext.origins[field]
|
||||
val descriptor = origin?.descriptor
|
||||
|
||||
val fieldAnnotations = when {
|
||||
!isIrBackend && descriptor is PropertyDescriptor -> descriptor.backingField?.annotations
|
||||
else -> descriptor?.annotations
|
||||
} ?: Annotations.EMPTY
|
||||
|
||||
val modifiers = convertModifiers(
|
||||
containingClass,
|
||||
field.access, ElementKind.FIELD, packageFqName,
|
||||
field.visibleAnnotations, field.invisibleAnnotations, fieldAnnotations
|
||||
field.visibleAnnotations, field.invisibleAnnotations,
|
||||
descriptor?.annotations ?: Annotations.EMPTY,
|
||||
)
|
||||
|
||||
val name = field.name
|
||||
|
||||
+1
-13
@@ -14,23 +14,11 @@ import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.test.Assertions
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.utils.withExtension
|
||||
import org.jetbrains.kotlin.test.utils.withSuffixAndExtension
|
||||
|
||||
fun Assertions.checkTxtAccordingToBackend(module: TestModule, actual: String, fileSuffix: String = "") {
|
||||
val testDataFile = module.files.first().originalFile
|
||||
val txtFile = testDataFile.withExtension("$fileSuffix.txt")
|
||||
val irTxtFile = testDataFile.withSuffixAndExtension("$fileSuffix.ir", ".txt")
|
||||
val isIr = module.targetBackend?.isIR == true
|
||||
val expectedFile = if (isIr && irTxtFile.exists()) {
|
||||
irTxtFile
|
||||
} else {
|
||||
txtFile
|
||||
}
|
||||
val expectedFile = testDataFile.withExtension("$fileSuffix.txt")
|
||||
assertEqualsToFile(expectedFile, actual)
|
||||
|
||||
if (isIr && txtFile.exists() && irTxtFile.exists() && txtFile.readText() == irTxtFile.readText()) {
|
||||
fail { "JVM and JVM_IR golden files are identical. Remove $irTxtFile." }
|
||||
}
|
||||
}
|
||||
|
||||
private val KOTLIN_METADATA_REGEX = "@kotlin\\.Metadata\\(.*\\)".toRegex()
|
||||
|
||||
@@ -160,19 +160,11 @@ internal class Kapt4Handler(testServices: TestServices) : AnalysisHandler<Kapt4C
|
||||
fun Assertions.checkTxt(module: TestModule, actual: String) {
|
||||
val testDataFile = module.files.first().originalFile
|
||||
val firFile = testDataFile.withExtension("fir.txt")
|
||||
val irFile = testDataFile.withExtension("ir.txt")
|
||||
val txtFile = testDataFile.withExtension("txt")
|
||||
val expectedFile = sequenceOf(firFile, irFile, txtFile)
|
||||
.firstOrNull { it.exists() } ?: firFile
|
||||
val expectedFile = if (firFile.exists()) firFile else txtFile
|
||||
|
||||
assertEqualsToFile(expectedFile, actual)
|
||||
if (firFile.exists()) {
|
||||
if (irFile.exists()) {
|
||||
if (irFile.readText() == firFile.readText()) {
|
||||
fail { ".fir.txt and .ir.txt golden files are identical. Remove $firFile." }
|
||||
}
|
||||
} else if (txtFile.exists() && txtFile.readText() == firFile.readText()) {
|
||||
fail { ".fir.txt and .txt golden files are identical. Remove $firFile." }
|
||||
}
|
||||
if (firFile.exists() && txtFile.exists() && txtFile.readText() == firFile.readText()) {
|
||||
fail { ".fir.txt and .txt golden files are identical. Remove $firFile." }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user