Move LANGUAGE_TO_METADATA_VERSION to compiler:frontend.common.jvm
This commit is contained in:
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.codegen.optimization.OptimizationClassBuilderFactory
|
||||
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings
|
||||
import org.jetbrains.kotlin.codegen.`when`.MappingsClassesForWhenByEnum
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.config.LanguageVersion.*
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
@@ -33,8 +32,6 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.idea.MainFunctionDetector
|
||||
import org.jetbrains.kotlin.load.java.components.JavaDeprecationSettings
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
|
||||
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
|
||||
import org.jetbrains.kotlin.modules.TargetId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
@@ -52,9 +49,9 @@ import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfigu
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeApproximator
|
||||
import org.jetbrains.kotlin.utils.metadataVersion
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
class GenerationState private constructor(
|
||||
val project: Project,
|
||||
@@ -347,7 +344,7 @@ class GenerationState private constructor(
|
||||
|
||||
val disableOptimization = configuration.get(JVMConfigurationKeys.DISABLE_OPTIMIZATION, false)
|
||||
|
||||
val metadataVersion = metadataVersion(configuration)
|
||||
val metadataVersion = configuration.metadataVersion()
|
||||
|
||||
val abiStability = configuration.get(JVMConfigurationKeys.ABI_STABILITY)
|
||||
|
||||
@@ -438,36 +435,6 @@ class GenerationState private constructor(
|
||||
fun recordNewFragmentCaptureParameter(string: String, type: KotlinType, descriptor: DeclarationDescriptor) {
|
||||
newFragmentCaptureParameters.add(Triple(string, type, descriptor))
|
||||
}
|
||||
|
||||
companion object {
|
||||
val LANGUAGE_TO_METADATA_VERSION = EnumMap<LanguageVersion, JvmMetadataVersion>(LanguageVersion::class.java).apply {
|
||||
val oldMetadataVersion = JvmMetadataVersion(1, 1, 18)
|
||||
this[KOTLIN_1_0] = oldMetadataVersion
|
||||
this[KOTLIN_1_1] = oldMetadataVersion
|
||||
this[KOTLIN_1_2] = oldMetadataVersion
|
||||
this[KOTLIN_1_3] = oldMetadataVersion
|
||||
this[KOTLIN_1_4] = JvmMetadataVersion(1, 4, 3)
|
||||
this[KOTLIN_1_5] = JvmMetadataVersion(1, 5, 1)
|
||||
this[KOTLIN_1_6] = JvmMetadataVersion(1, 6, 0)
|
||||
this[KOTLIN_1_7] = JvmMetadataVersion(1, 7, 0)
|
||||
this[KOTLIN_1_8] = JvmMetadataVersion.INSTANCE
|
||||
this[KOTLIN_1_9] = JvmMetadataVersion(1, 9, 0)
|
||||
this[KOTLIN_2_0] = JvmMetadataVersion(2, 0, 0)
|
||||
|
||||
check(size == LanguageVersion.values().size) {
|
||||
"Please add mappings from the missing LanguageVersion instances to the corresponding JvmMetadataVersion " +
|
||||
"in `GenerationState.LANGUAGE_TO_METADATA_VERSION`"
|
||||
}
|
||||
}
|
||||
|
||||
fun metadataVersion(
|
||||
configuration: CompilerConfiguration,
|
||||
languageVersionSettings: LanguageVersionSettings = configuration.languageVersionSettings
|
||||
): BinaryVersion {
|
||||
return configuration.get(CommonConfigurationKeys.METADATA_VERSION)
|
||||
?: LANGUAGE_TO_METADATA_VERSION.getValue(languageVersionSettings.languageVersion)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val doNotGenerateInLightClassMode = setOf(CLASS_MEMBER_DELEGATION_TO_DEFAULT_IMPL, BRIDGE, COLLECTION_STUB, AUGMENTED_BUILTIN_API)
|
||||
|
||||
@@ -97,6 +97,7 @@ import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
import org.jetbrains.kotlin.utils.KotlinPaths
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import org.jetbrains.kotlin.utils.join
|
||||
import org.jetbrains.kotlin.utils.metadataVersion
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.nio.file.Paths
|
||||
@@ -609,7 +610,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
// TODO: expect -> actual mapping
|
||||
val expectDescriptorToSymbol = mutableMapOf<DeclarationDescriptor, IrSymbol>()
|
||||
|
||||
val metadataVersion = GenerationState.metadataVersion(configuration)
|
||||
val metadataVersion = configuration.metadataVersion()
|
||||
|
||||
serializeModuleIntoKlib(
|
||||
configuration[CommonConfigurationKeys.MODULE_NAME]!!,
|
||||
|
||||
+2
-1
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.protobuf.MessageLite
|
||||
import org.jetbrains.kotlin.types.AbstractTypeApproximator
|
||||
import org.jetbrains.kotlin.types.TypeApproximatorConfiguration
|
||||
import org.jetbrains.kotlin.utils.metadataVersion
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.Method
|
||||
|
||||
@@ -92,7 +93,7 @@ fun makeLocalFirMetadataSerializerForMetadataSource(
|
||||
configuration.getBoolean(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS),
|
||||
session.languageVersionSettings.apiVersion >= ApiVersion.KOTLIN_1_4 &&
|
||||
!configuration.getBoolean(JVMConfigurationKeys.NO_UNIFIED_NULL_CHECKS),
|
||||
GenerationState.metadataVersion(configuration, session.languageVersionSettings),
|
||||
configuration.metadataVersion(session.languageVersionSettings.languageVersion),
|
||||
session.languageVersionSettings.getFlag(JvmAnalysisFlags.jvmDefaultMode),
|
||||
stringTable
|
||||
)
|
||||
|
||||
@@ -10,6 +10,7 @@ dependencies {
|
||||
api(project(":compiler:config.jvm"))
|
||||
api(project(":compiler:resolution.common.jvm"))
|
||||
api(project(":compiler:frontend.common"))
|
||||
api(project(":compiler:frontend.common.jvm"))
|
||||
// api(project(":compiler:fir:resolve"))
|
||||
api(project(":compiler:fir:resolve"))
|
||||
api(project(":compiler:fir:checkers"))
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.utils
|
||||
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
|
||||
import java.util.*
|
||||
|
||||
private val LANGUAGE_TO_METADATA_VERSION = EnumMap<LanguageVersion, JvmMetadataVersion>(LanguageVersion::class.java).apply {
|
||||
val oldMetadataVersion = JvmMetadataVersion(1, 1, 18)
|
||||
this[LanguageVersion.KOTLIN_1_0] = oldMetadataVersion
|
||||
this[LanguageVersion.KOTLIN_1_1] = oldMetadataVersion
|
||||
this[LanguageVersion.KOTLIN_1_2] = oldMetadataVersion
|
||||
this[LanguageVersion.KOTLIN_1_3] = oldMetadataVersion
|
||||
this[LanguageVersion.KOTLIN_1_4] = JvmMetadataVersion(1, 4, 3)
|
||||
this[LanguageVersion.KOTLIN_1_5] = JvmMetadataVersion(1, 5, 1)
|
||||
this[LanguageVersion.KOTLIN_1_6] = JvmMetadataVersion(1, 6, 0)
|
||||
this[LanguageVersion.KOTLIN_1_7] = JvmMetadataVersion(1, 7, 0)
|
||||
this[LanguageVersion.KOTLIN_1_8] = JvmMetadataVersion.INSTANCE
|
||||
this[LanguageVersion.KOTLIN_1_9] = JvmMetadataVersion(1, 9, 0)
|
||||
this[LanguageVersion.KOTLIN_2_0] = JvmMetadataVersion(2, 0, 0)
|
||||
|
||||
check(size == LanguageVersion.values().size) {
|
||||
"Please add mappings from the missing LanguageVersion instances to the corresponding JvmMetadataVersion " +
|
||||
"in `LANGUAGE_TO_METADATA_VERSION`"
|
||||
}
|
||||
}
|
||||
|
||||
fun LanguageVersion.toMetadataVersion(): JvmMetadataVersion = LANGUAGE_TO_METADATA_VERSION.getValue(this)
|
||||
|
||||
fun CompilerConfiguration.metadataVersion(
|
||||
languageVersion: LanguageVersion = languageVersionSettings.languageVersion
|
||||
): BinaryVersion {
|
||||
return get(CommonConfigurationKeys.METADATA_VERSION) ?: languageVersion.toMetadataVersion()
|
||||
}
|
||||
+2
-3
@@ -8,8 +8,6 @@ package org.jetbrains.kotlin.test.frontend.fir
|
||||
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureDescriptor
|
||||
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
@@ -51,6 +49,7 @@ import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.compilerConfigurationProvider
|
||||
import org.jetbrains.kotlin.test.services.jsLibraryProvider
|
||||
import org.jetbrains.kotlin.utils.metadataVersion
|
||||
|
||||
class Fir2IrJsResultsConverter(
|
||||
testServices: TestServices
|
||||
@@ -76,7 +75,7 @@ class Fir2IrJsResultsConverter(
|
||||
|
||||
val icData = configuration.incrementalDataProvider?.getSerializedData(sourceFiles) ?: emptyList()
|
||||
val expectDescriptorToSymbol = mutableMapOf<DeclarationDescriptor, IrSymbol>()
|
||||
val metadataVersion = GenerationState.metadataVersion(configuration, module.languageVersionSettings)
|
||||
val metadataVersion = configuration.metadataVersion(module.languageVersionSettings.languageVersion)
|
||||
|
||||
// At this point, checkers will already have been run by a previous test step. `runCheckers` returns the cached diagnostics map.
|
||||
val diagnosticsMap = inputArtifact.partsForDependsOnModules.last().firAnalyzerFacade.runCheckers()
|
||||
|
||||
+2
-2
@@ -8,7 +8,6 @@ import org.jetbrains.kotlin.backend.konan.driver.PhaseContext
|
||||
import org.jetbrains.kotlin.backend.konan.driver.phases.Fir2IrOutput
|
||||
import org.jetbrains.kotlin.backend.konan.driver.phases.SerializerOutput
|
||||
import org.jetbrains.kotlin.backend.konan.serialization.KonanIrModuleSerializer
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
@@ -21,6 +20,7 @@ import org.jetbrains.kotlin.konan.library.KonanLibrary
|
||||
import org.jetbrains.kotlin.library.SerializedIrFile
|
||||
import org.jetbrains.kotlin.library.metadata.resolver.TopologicalLibraryOrder
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.utils.toMetadataVersion
|
||||
|
||||
internal fun PhaseContext.firSerializer(
|
||||
input: Fir2IrOutput
|
||||
@@ -30,7 +30,7 @@ internal fun PhaseContext.firSerializer(
|
||||
val firFilesBySourceFile = input.firFiles.associateBy { it.sourceFile }
|
||||
val metadataVersion =
|
||||
configuration.get(CommonConfigurationKeys.METADATA_VERSION)
|
||||
?: GenerationState.LANGUAGE_TO_METADATA_VERSION.getValue(configuration.languageVersionSettings.languageVersion)
|
||||
?: configuration.languageVersionSettings.languageVersion.toMetadataVersion()
|
||||
|
||||
val resolvedLibraries = config.resolvedLibraries.getFullResolvedList(TopologicalLibraryOrder) // FIXME KT-55603
|
||||
return serializeNativeModule(
|
||||
|
||||
Reference in New Issue
Block a user