Update JVM metadata version to 1.5.0
Improve the test which checks that we use correct metadata version if `-language-version` is passed by checking all supported language versions. The change in libraries/reflect/build.gradle.kts is needed because kotlinx-metadata-jvm of version 0.1.0 is based on pre-1.4 Kotlin, which doesn't support the new module file metadata generated with metadata version 1.4 and later, and module files need to be readable there to be able to transform them for the shadow plugin. Similarly override dependency on kotlinx-metadata-jvm in the binary-compatibility-validator module.
This commit is contained in:
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicMethods
|
||||
import org.jetbrains.kotlin.codegen.optimization.OptimizationClassBuilderFactory
|
||||
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.config.LanguageVersion.*
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
|
||||
@@ -49,6 +50,7 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeApproximator
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
class GenerationState private constructor(
|
||||
val project: Project,
|
||||
@@ -320,8 +322,7 @@ class GenerationState private constructor(
|
||||
|
||||
val metadataVersion =
|
||||
configuration.get(CommonConfigurationKeys.METADATA_VERSION)
|
||||
?: if (languageVersionSettings.languageVersion >= LanguageVersion.LATEST_STABLE) JvmMetadataVersion.INSTANCE
|
||||
else JvmMetadataVersion(1, 1, 18)
|
||||
?: LANGUAGE_TO_METADATA_VERSION.getValue(languageVersionSettings.languageVersion)
|
||||
|
||||
val abiStability = configuration.get(JVMConfigurationKeys.ABI_STABILITY)
|
||||
|
||||
@@ -392,6 +393,24 @@ class GenerationState private constructor(
|
||||
|
||||
private fun shouldOnlyCollectSignatures(origin: JvmDeclarationOrigin) =
|
||||
classBuilderMode == ClassBuilderMode.LIGHT_CLASSES && origin.originKind in doNotGenerateInLightClassMode
|
||||
|
||||
companion object {
|
||||
private 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.INSTANCE
|
||||
this[KOTLIN_1_6] = JvmMetadataVersion(1, 6, 0)
|
||||
|
||||
check(size == LanguageVersion.values().size) {
|
||||
"Please add mappings from the missing LanguageVersion instances to the corresponding JvmMetadataVersion " +
|
||||
"in `GenerationState.LANGUAGE_TO_METADATA_VERSION`"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val doNotGenerateInLightClassMode = setOf(CLASS_MEMBER_DELEGATION_TO_DEFAULT_IMPL, BRIDGE, COLLECTION_STUB, AUGMENTED_BUILTIN_API)
|
||||
|
||||
Reference in New Issue
Block a user