diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/writeAnnotationUtil.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/writeAnnotationUtil.kt index 0aae2d1e590..291fdae9571 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/writeAnnotationUtil.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/writeAnnotationUtil.kt @@ -37,7 +37,9 @@ fun writeKotlinMetadata( av.visit(JvmAnnotationNames.BYTECODE_VERSION_FIELD_NAME, JvmBytecodeBinaryVersion.INSTANCE.toArray()) av.visit(JvmAnnotationNames.KIND_FIELD_NAME, kind.id) var flags = extraFlags - if (KotlinCompilerVersion.isPreRelease() && state.languageVersionSettings.languageVersion == LanguageVersion.LATEST_STABLE) { + val languageVersion = state.languageVersionSettings.languageVersion + if (KotlinCompilerVersion.isPreRelease() && languageVersion == LanguageVersion.LATEST_STABLE || + !languageVersion.isStable) { flags = flags or JvmAnnotationNames.METADATA_PRE_RELEASE_FLAG } if (flags != 0) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompilerDeserializationConfiguration.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompilerDeserializationConfiguration.kt index 0acf782975b..654d1080e40 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompilerDeserializationConfiguration.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompilerDeserializationConfiguration.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfigu class CompilerDeserializationConfiguration(languageVersionSettings: LanguageVersionSettings) : DeserializationConfiguration { override val skipMetadataVersionCheck = languageVersionSettings.getFlag(AnalysisFlag.skipMetadataVersionCheck) - override val skipPreReleaseCheck = skipMetadataVersionCheck + override val skipPreReleaseCheck = skipMetadataVersionCheck || !languageVersionSettings.languageVersion.isStable override val typeAliasesAllowed = languageVersionSettings.supportsFeature(LanguageFeature.TypeAliases) diff --git a/core/util.runtime/src/org/jetbrains/kotlin/config/KotlinCompilerVersion.java b/core/util.runtime/src/org/jetbrains/kotlin/config/KotlinCompilerVersion.java index a521acbc44f..b470d1059af 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/config/KotlinCompilerVersion.java +++ b/core/util.runtime/src/org/jetbrains/kotlin/config/KotlinCompilerVersion.java @@ -21,8 +21,9 @@ public class KotlinCompilerVersion { // DON'T MODIFY IT public static final String VERSION = "@snapshot@"; - // True if this compiler is of a non-stable (EAP or Beta) version. - // Binaries produced by this compiler can not be loaded by release versions of the compiler. + // True if the latest stable language version supported by this compiler has not yet been released. + // Binaries produced by this compiler with that language version (or any future language version) are going to be marked + // as "pre-release" and will not be loaded by release versions of the compiler. // Change this value before and after every major release private static final boolean IS_PRE_RELEASE = false; @@ -38,6 +39,7 @@ public class KotlinCompilerVersion { } static { + //noinspection ConstantConditions if (!VERSION.equals("@snapshot@") && !VERSION.contains("-") && IS_PRE_RELEASE) { throw new IllegalStateException( "IS_PRE_RELEASE cannot be true for a compiler without '-' in its version.\n" +