Deserialization/class reading: pass chosen JvmMetadataVersion whenever possible
This commit is contained in:
+10
-3
@@ -32,8 +32,8 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.compilerRunner.MessageCollectorToOutputItemsCollectorAdapter
|
||||
import org.jetbrains.kotlin.compilerRunner.OutputItemsCollectorImpl
|
||||
import org.jetbrains.kotlin.compilerRunner.SimpleOutputItem
|
||||
import org.jetbrains.kotlin.compilerRunner.toGeneratedFile
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.config.Services
|
||||
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
@@ -41,9 +41,11 @@ import org.jetbrains.kotlin.incremental.parsing.classesFqNames
|
||||
import org.jetbrains.kotlin.incremental.util.BufferingMessageCollector
|
||||
import org.jetbrains.kotlin.incremental.util.ExceptionLocation
|
||||
import org.jetbrains.kotlin.incremental.util.reportException
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.progress.CompilationCanceledStatus
|
||||
import org.jetbrains.kotlin.util.removeSuffixIfPresent
|
||||
import org.jetbrains.kotlin.utils.toMetadataVersion
|
||||
import java.io.File
|
||||
|
||||
abstract class IncrementalCompilerRunner<
|
||||
@@ -411,6 +413,10 @@ abstract class IncrementalCompilerRunner<
|
||||
|
||||
var exitCode = ExitCode.OK
|
||||
|
||||
// TODO: ideally we should read arguments not here but at earlier stages
|
||||
val jvmMetadataVersionFromLanguageVersion =
|
||||
LanguageVersion.fromVersionString(args.languageVersion)?.toMetadataVersion() ?: JvmMetadataVersion.INSTANCE
|
||||
|
||||
while (dirtySources.any() || runWithNoDirtyKotlinSources(caches)) {
|
||||
val complementaryFiles = caches.platformCache.getComplementaryFilesRecursive(dirtySources)
|
||||
dirtySources.addAll(complementaryFiles)
|
||||
@@ -447,8 +453,9 @@ abstract class IncrementalCompilerRunner<
|
||||
val text = allDirtySources.joinToString(separator = System.getProperty("line.separator")) { it.normalize().absolutePath }
|
||||
dirtySourcesSinceLastTimeFile.writeText(text)
|
||||
|
||||
|
||||
val generatedFiles = outputItemsCollector.outputs.map(SimpleOutputItem::toGeneratedFile)
|
||||
val generatedFiles = outputItemsCollector.outputs.map {
|
||||
it.toGeneratedFile(jvmMetadataVersionFromLanguageVersion)
|
||||
}
|
||||
if (compilationMode is CompilationMode.Incremental) {
|
||||
// todo: feels dirty, can this be refactored?
|
||||
val dirtySourcesSet = dirtySources.toHashSet()
|
||||
|
||||
+4
-2
@@ -40,6 +40,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.cli.jvm.config.configureJdkClasspathRoots
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.config.Services
|
||||
import org.jetbrains.kotlin.incremental.ClasspathChanges.ClasspathSnapshotDisabled
|
||||
import org.jetbrains.kotlin.incremental.ClasspathChanges.ClasspathSnapshotEnabled.IncrementalRun.NoChanges
|
||||
@@ -85,8 +86,9 @@ fun makeIncrementally(
|
||||
val buildReporter = BuildReporter(icReporter = reporter, buildMetricsReporter = DoNothingBuildMetricsReporter)
|
||||
|
||||
withIC(args) {
|
||||
val useK2 = args.useK2 || LanguageVersion.fromVersionString(args.languageVersion)?.usesK2 == true
|
||||
val compiler =
|
||||
if (args.useK2 && args.useFirIC && args.useFirLT /* TODO: move LT check into runner */ )
|
||||
if (useK2 && args.useFirIC && args.useFirLT /* TODO: move LT check into runner */)
|
||||
IncrementalFirJvmCompilerRunner(
|
||||
cachesDir,
|
||||
buildReporter,
|
||||
@@ -101,7 +103,7 @@ fun makeIncrementally(
|
||||
cachesDir,
|
||||
buildReporter,
|
||||
// Use precise setting in case of non-Gradle build
|
||||
usePreciseJavaTracking = !args.useK2, // TODO: add fir-based java classes tracker when available and set this to true
|
||||
usePreciseJavaTracking = !useK2, // TODO: add fir-based java classes tracker when available and set this to true
|
||||
buildHistoryFile = buildHistoryFile,
|
||||
outputDirs = null,
|
||||
modulesApiHistory = EmptyModulesApiHistory,
|
||||
|
||||
+1
-1
@@ -107,5 +107,5 @@ private class KotlinClassHeaderClassVisitor : ClassVisitor(Opcodes.API_VERSION)
|
||||
)
|
||||
}
|
||||
|
||||
fun getKotlinClassHeader(): KotlinClassHeader? = kotlinClassHeaderAnnotationVisitor.createHeader()
|
||||
fun getKotlinClassHeader(): KotlinClassHeader? = kotlinClassHeaderAnnotationVisitor.createHeaderWithDefaultMetadataVersion()
|
||||
}
|
||||
|
||||
+1
@@ -13,6 +13,7 @@ abstract class AbstractIncrementalFirICLightTreeJvmCompilerRunnerTest : Abstract
|
||||
override fun createCompilerArguments(destinationDir: File, testDir: File): K2JVMCompilerArguments =
|
||||
super.createCompilerArguments(destinationDir, testDir).apply {
|
||||
useK2 = true
|
||||
languageVersion = "2.0"
|
||||
useIR = true
|
||||
useFirIC = true
|
||||
useFirLT = true
|
||||
|
||||
+1
@@ -24,6 +24,7 @@ abstract class AbstractIncrementalFirJvmCompilerRunnerTest : AbstractIncremental
|
||||
override fun createCompilerArguments(destinationDir: File, testDir: File): K2JVMCompilerArguments =
|
||||
super.createCompilerArguments(destinationDir, testDir).apply {
|
||||
useK2 = true
|
||||
languageVersion = "2.0"
|
||||
useIR = true
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -13,6 +13,7 @@ abstract class AbstractIncrementalFirLightTreeJvmCompilerRunnerTest : AbstractIn
|
||||
override fun createCompilerArguments(destinationDir: File, testDir: File): K2JVMCompilerArguments =
|
||||
super.createCompilerArguments(destinationDir, testDir).apply {
|
||||
useK2 = true
|
||||
languageVersion = "2.0"
|
||||
useIR = true
|
||||
useFirIC = false
|
||||
useFirLT = true
|
||||
|
||||
Reference in New Issue
Block a user