diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt index f6180d7fa04..f7918fcd766 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt @@ -89,10 +89,13 @@ abstract class CommonCompilerArguments : CommonToolArguments() { @Argument( value = "-Xskip-metadata-version-check", - description = "Load classes with bad metadata version anyway (incl. pre-release classes)" + description = "Allow to load classes with bad metadata version and pre-release classes" ) var skipMetadataVersionCheck: Boolean by FreezableVar(false) + @Argument(value = "-Xskip-prerelease-check", description = "Allow to load pre-release classes") + var skipPrereleaseCheck: Boolean by FreezableVar(false) + @Argument( value = "-Xallow-kotlin-package", description = "Allow compiling code in package 'kotlin' and allow not requiring kotlin.stdlib in module-info" @@ -340,6 +343,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() { open fun configureAnalysisFlags(collector: MessageCollector): MutableMap, Any> { return HashMap, Any>().apply { put(AnalysisFlags.skipMetadataVersionCheck, skipMetadataVersionCheck) + put(AnalysisFlags.skipPrereleaseCheck, skipPrereleaseCheck || skipMetadataVersionCheck) put(AnalysisFlags.multiPlatformDoNotCheckActual, noCheckActual) val experimentalFqNames = experimental?.toList().orEmpty() if (experimentalFqNames.isNotEmpty()) { diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/AnalyzerWithCompilerReport.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/AnalyzerWithCompilerReport.kt index 298efd641fe..99cc012be97 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/AnalyzerWithCompilerReport.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/AnalyzerWithCompilerReport.kt @@ -166,7 +166,7 @@ class AnalyzerWithCompilerReport( fun reportDiagnostics(diagnostics: Diagnostics, messageCollector: MessageCollector): Boolean { val hasErrors = reportDiagnostics(diagnostics, DefaultDiagnosticReporter(messageCollector)) - if (diagnostics.any { it.factory == Errors.INCOMPATIBLE_CLASS || it.factory == Errors.PRE_RELEASE_CLASS }) { + if (diagnostics.any { it.factory == Errors.INCOMPATIBLE_CLASS }) { messageCollector.report( ERROR, "Incompatible classes were found in dependencies. " + @@ -174,6 +174,15 @@ class AnalyzerWithCompilerReport( ) } + if (diagnostics.any { it.factory == Errors.PRE_RELEASE_CLASS }) { + messageCollector.report( + ERROR, + "Pre-release classes were found in dependencies. " + + "Remove them from the classpath, recompile with a release compiler " + + "or use '-Xskip-prerelease-check' to suppress errors" + ) + } + if (diagnostics.any { it.factory == Errors.IR_COMPILED_CLASS }) { messageCollector.report( ERROR, diff --git a/compiler/config/src/org/jetbrains/kotlin/config/AnalysisFlags.kt b/compiler/config/src/org/jetbrains/kotlin/config/AnalysisFlags.kt index e560cfd5d85..46a5700bc05 100644 --- a/compiler/config/src/org/jetbrains/kotlin/config/AnalysisFlags.kt +++ b/compiler/config/src/org/jetbrains/kotlin/config/AnalysisFlags.kt @@ -9,6 +9,9 @@ object AnalysisFlags { @JvmStatic val skipMetadataVersionCheck by AnalysisFlag.Delegates.Boolean + @JvmStatic + val skipPrereleaseCheck by AnalysisFlag.Delegates.Boolean + @JvmStatic val multiPlatformDoNotCheckActual by AnalysisFlag.Delegates.Boolean diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompilerDeserializationConfiguration.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompilerDeserializationConfiguration.kt index 217452b661b..84fe95ab7e3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompilerDeserializationConfiguration.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompilerDeserializationConfiguration.kt @@ -14,8 +14,10 @@ import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfigu class CompilerDeserializationConfiguration(languageVersionSettings: LanguageVersionSettings) : DeserializationConfiguration { override val skipMetadataVersionCheck = languageVersionSettings.getFlag(AnalysisFlags.skipMetadataVersionCheck) + override val skipPrereleaseCheck = languageVersionSettings.getFlag(AnalysisFlags.skipPrereleaseCheck) + override val reportErrorsOnPreReleaseDependencies = - !skipMetadataVersionCheck && !languageVersionSettings.isPreRelease() && !KotlinCompilerVersion.isPreRelease() + !skipPrereleaseCheck && !languageVersionSettings.isPreRelease() && !KotlinCompilerVersion.isPreRelease() override val reportErrorsOnIrDependencies = languageVersionSettings.getFlag(AnalysisFlags.reportErrorsOnIrDependencies) diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index c8a449397a5..d45d3e2a390 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -62,7 +62,8 @@ where advanced options include: -Xread-deserialized-contracts Enable reading of contracts from metadata -Xreport-output-files Report source to output files mapping -Xreport-perf Report detailed performance statistics - -Xskip-metadata-version-check Load classes with bad metadata version anyway (incl. pre-release classes) + -Xskip-metadata-version-check Allow to load classes with bad metadata version and pre-release classes + -Xskip-prerelease-check Allow to load pre-release classes -Xuse-experimental= Enable, but don't propagate usages of experimental API for marker annotation with the given fully qualified name -Xuse-fir Compile using Front-end IR. Warning: this feature is far from being production-ready -Xuse-mixed-named-arguments Enable Support named arguments in their own position even if the result appears as mixed diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index 6640cf273ab..4d31487618c 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -140,7 +140,8 @@ where advanced options include: -Xread-deserialized-contracts Enable reading of contracts from metadata -Xreport-output-files Report source to output files mapping -Xreport-perf Report detailed performance statistics - -Xskip-metadata-version-check Load classes with bad metadata version anyway (incl. pre-release classes) + -Xskip-metadata-version-check Allow to load classes with bad metadata version and pre-release classes + -Xskip-prerelease-check Allow to load pre-release classes -Xuse-experimental= Enable, but don't propagate usages of experimental API for marker annotation with the given fully qualified name -Xuse-fir Compile using Front-end IR. Warning: this feature is far from being production-ready -Xuse-mixed-named-arguments Enable Support named arguments in their own position even if the result appears as mixed diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrary/output.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrary/output.txt index dfccedf239a..c261b63b833 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrary/output.txt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrary/output.txt @@ -1,4 +1,4 @@ -error: incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors +error: pre-release classes were found in dependencies. Remove them from the classpath, recompile with a release compiler or use '-Xskip-prerelease-check' to suppress errors compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrary/source.kt:5:16: error: class 'a.A' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler fun baz(param: A, nested: A.Nested) { ^ diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJs/output.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJs/output.txt index da733c44417..4bc18ed5cef 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJs/output.txt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJs/output.txt @@ -1,4 +1,4 @@ -error: incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors +error: pre-release classes were found in dependencies. Remove them from the classpath, recompile with a release compiler or use '-Xskip-prerelease-check' to suppress errors compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJs/source.kt:5:16: error: package 'a' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler fun baz(param: A, nested: A.Nested) { ^ @@ -38,4 +38,4 @@ compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreRe compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJs/source.kt:14:12: error: package 'a' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler val z: TA = "" ^ -COMPILATION_ERROR \ No newline at end of file +COMPILATION_ERROR diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJsSkipVersionCheck/library/a.kt b/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJsSkipPrereleaseCheck/library/a.kt similarity index 100% rename from compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJsSkipVersionCheck/library/a.kt rename to compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJsSkipPrereleaseCheck/library/a.kt diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJsSkipVersionCheck/output.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJsSkipPrereleaseCheck/output.txt similarity index 100% rename from compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJsSkipVersionCheck/output.txt rename to compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJsSkipPrereleaseCheck/output.txt diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJsSkipVersionCheck/source.kt b/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJsSkipPrereleaseCheck/source.kt similarity index 100% rename from compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJsSkipVersionCheck/source.kt rename to compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibraryJsSkipPrereleaseCheck/source.kt diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipVersionCheck/library/a.kt b/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipMetadataVersionCheck/library/a.kt similarity index 100% rename from compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipVersionCheck/library/a.kt rename to compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipMetadataVersionCheck/library/a.kt diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipVersionCheck/output.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipMetadataVersionCheck/output.txt similarity index 100% rename from compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipVersionCheck/output.txt rename to compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipMetadataVersionCheck/output.txt diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipVersionCheck/source.kt b/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipMetadataVersionCheck/source.kt similarity index 100% rename from compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipVersionCheck/source.kt rename to compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipMetadataVersionCheck/source.kt diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipPrereleaseCheck/library/a.kt b/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipPrereleaseCheck/library/a.kt new file mode 100644 index 00000000000..a311bb96854 --- /dev/null +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipPrereleaseCheck/library/a.kt @@ -0,0 +1,9 @@ +package a + +open class A { + class Nested +} + +fun foo() {} +var bar = 42 +typealias TA = String diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipPrereleaseCheck/output.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipPrereleaseCheck/output.txt new file mode 100644 index 00000000000..a0aba9318ad --- /dev/null +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipPrereleaseCheck/output.txt @@ -0,0 +1 @@ +OK \ No newline at end of file diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipPrereleaseCheck/source.kt b/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipPrereleaseCheck/source.kt new file mode 100644 index 00000000000..6f6e9ef8209 --- /dev/null +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/releaseCompilerAgainstPreReleaseLibrarySkipPrereleaseCheck/source.kt @@ -0,0 +1,15 @@ +@file:Suppress("UNUSED_VARIABLE") +package usage + +import a.* + +fun baz(param: A) { + val constructor = A() + val methodCall = param.hashCode() + val supertype = object : A() {} + + val x = foo() + val y = bar + bar = 239 + val z: TA = "" +} diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/library/a.kt b/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/library/a.kt new file mode 100644 index 00000000000..2dc03d6b5da --- /dev/null +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/library/a.kt @@ -0,0 +1,11 @@ +package a + +open class A { + class Nested + + fun method() {} +} + +fun foo() {} +var bar = 42 +typealias TA = String diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/output.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/output.txt new file mode 100644 index 00000000000..e26ada18674 --- /dev/null +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/output.txt @@ -0,0 +1,47 @@ +error: incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors +$TMP_DIR$/library-after.jar!/META-INF/main.kotlin_module: error: module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 42.0.0, expected version is $ABI_VERSION$. +compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt:5:16: error: class 'a.A' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 42.0.0, expected version is $ABI_VERSION$. +The class is loaded from $TMP_DIR$/library-after.jar!/a/A.class +fun baz(param: A, nested: A.Nested) { + ^ +compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt:5:27: error: class 'a.A' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 42.0.0, expected version is $ABI_VERSION$. +The class is loaded from $TMP_DIR$/library-after.jar!/a/A.class +fun baz(param: A, nested: A.Nested) { + ^ +compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt:5:29: error: class 'a.A.Nested' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 42.0.0, expected version is $ABI_VERSION$. +The class is loaded from $TMP_DIR$/library-after.jar!/a/A$Nested.class +fun baz(param: A, nested: A.Nested) { + ^ +compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt:6:23: error: class 'a.A' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 42.0.0, expected version is $ABI_VERSION$. +The class is loaded from $TMP_DIR$/library-after.jar!/a/A.class + val constructor = A() + ^ +compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt:7:18: error: class 'a.A' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 42.0.0, expected version is $ABI_VERSION$. +The class is loaded from $TMP_DIR$/library-after.jar!/a/A.class + val nested = A.Nested() + ^ +compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt:7:20: error: class 'a.A.Nested' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 42.0.0, expected version is $ABI_VERSION$. +The class is loaded from $TMP_DIR$/library-after.jar!/a/A$Nested.class + val nested = A.Nested() + ^ +compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt:8:22: error: class 'a.A' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 42.0.0, expected version is $ABI_VERSION$. +The class is loaded from $TMP_DIR$/library-after.jar!/a/A.class + val methodCall = param.method() + ^ +compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt:9:30: error: class 'a.A' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 42.0.0, expected version is $ABI_VERSION$. +The class is loaded from $TMP_DIR$/library-after.jar!/a/A.class + val supertype = object : A() {} + ^ +compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt:11:13: error: unresolved reference: foo + val x = foo() + ^ +compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt:12:13: error: unresolved reference: bar + val y = bar + ^ +compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt:13:5: error: unresolved reference: bar + bar = 239 + ^ +compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt:14:12: error: unresolved reference: TA + val z: TA = "" + ^ +COMPILATION_ERROR diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt b/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt new file mode 100644 index 00000000000..f15b2e0bd70 --- /dev/null +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt @@ -0,0 +1,15 @@ +package usage + +import a.* + +fun baz(param: A, nested: A.Nested) { + val constructor = A() + val nested = A.Nested() + val methodCall = param.method() + val supertype = object : A() {} + + val x = foo() + val y = bar + bar = 239 + val z: TA = "" +} diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt index 55c66caf65c..52520db4646 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt @@ -295,12 +295,16 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration doTestPreReleaseKotlinLibrary(K2JSCompiler(), "library", File(tmpdir, "usage.js")) } - fun testReleaseCompilerAgainstPreReleaseLibrarySkipVersionCheck() { - doTestPreReleaseKotlinLibrary(K2JVMCompiler(), "library", tmpdir, "-Xskip-metadata-version-check") + fun testReleaseCompilerAgainstPreReleaseLibrarySkipPrereleaseCheck() { + doTestPreReleaseKotlinLibrary(K2JVMCompiler(), "library", tmpdir, "-Xskip-prerelease-check") } - fun testReleaseCompilerAgainstPreReleaseLibraryJsSkipVersionCheck() { - doTestPreReleaseKotlinLibrary(K2JSCompiler(), "library", File(tmpdir, "usage.js"), "-Xskip-metadata-version-check") + fun testReleaseCompilerAgainstPreReleaseLibraryJsSkipPrereleaseCheck() { + doTestPreReleaseKotlinLibrary(K2JSCompiler(), "library", File(tmpdir, "usage.js"), "-Xskip-prerelease-check") + } + + fun testReleaseCompilerAgainstPreReleaseLibrarySkipMetadataVersionCheck() { + doTestPreReleaseKotlinLibrary(K2JVMCompiler(), "library", tmpdir, "-Xskip-metadata-version-check") } fun testPreReleaseCompilerAgainstPreReleaseLibraryStableLanguageVersion() { @@ -362,6 +366,10 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration doTestKotlinLibraryWithWrongMetadataVersionJs("library", "-Xskip-metadata-version-check") } + fun testWrongMetadataVersionSkipPrereleaseCheckHasNoEffect() { + doTestKotlinLibraryWithWrongMetadataVersion("library", null, "-Xskip-prerelease-check") + } + fun testRequireKotlin() { compileKotlin("source.kt", tmpdir, listOf(compileLibrary("library"))) } diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/DeserializedDescriptorResolver.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/DeserializedDescriptorResolver.kt index 053837be1d7..65278113123 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/DeserializedDescriptorResolver.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/DeserializedDescriptorResolver.kt @@ -94,7 +94,7 @@ class DeserializedDescriptorResolver { // We report pre-release errors on .class files produced by 1.3-M1 even if this compiler is pre-release. This is needed because // 1.3-M1 did not mangle names of functions mentioning inline classes yet, and we don't want to support this case in the codegen private val KotlinJvmBinaryClass.isCompiledWith13M1: Boolean - get() = !components.configuration.skipMetadataVersionCheck && + get() = !components.configuration.skipPrereleaseCheck && classHeader.isPreRelease && classHeader.metadataVersion == KOTLIN_1_3_M1_METADATA_VERSION private val KotlinJvmBinaryClass.isInvisibleJvmIrDependency: Boolean diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializationConfiguration.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializationConfiguration.kt index a7748582dbb..624b32a0b71 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializationConfiguration.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializationConfiguration.kt @@ -9,6 +9,9 @@ interface DeserializationConfiguration { val skipMetadataVersionCheck: Boolean get() = false + val skipPrereleaseCheck: Boolean + get() = false + val reportErrorsOnPreReleaseDependencies: Boolean get() = false