From 007248620ce577f0ff0310bb1df92ce4c9966a26 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 9 Feb 2018 18:57:51 +0100 Subject: [PATCH] Disable API version inference when "-language-version" is specified API version inference happens in JvmRuntimeVersionsConsistencyChecker.checkCompilerClasspathConsistency only in the case when API version is specified explicitly (with "-api-version ..."). However, if the user specifies "-language-version 1.3", what's likely meant is "-language-version 1.3 -api-version 1.3", and it would be unwise to infer API version to 1.2 (which is the version of the attached stdlib) in this case. Therefore, API version is now considered to be specified explicitly if _either_ -language-version or -api-version is specified on the command line #KT-22777 In Progress --- .../org/jetbrains/kotlin/cli/common/CLICompiler.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java index 84673443a4b..ff0810eecc3 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java @@ -165,19 +165,20 @@ public abstract class CLICompiler extends CLI LanguageVersion languageVersion = parseVersion(configuration, arguments.getLanguageVersion(), "language"); LanguageVersion apiVersion = parseVersion(configuration, arguments.getApiVersion(), "API"); + if (languageVersion != null || apiVersion != null) { + configuration.put(CLIConfigurationKeys.IS_API_VERSION_EXPLICIT, true); + } + if (languageVersion == null) { - // If only "-api-version" is specified, language version is assumed to be the latest stable + // If no "-language-version" is specified, language version is assumed to be the latest stable languageVersion = LanguageVersion.LATEST_STABLE; } if (apiVersion == null) { - // If only "-language-version" is specified, API version is assumed to be equal to the language version + // If no "-api-version" is specified, API version is assumed to be equal to the language version // (API version cannot be greater than the language version) apiVersion = languageVersion; } - else { - configuration.put(CLIConfigurationKeys.IS_API_VERSION_EXPLICIT, true); - } MessageCollector collector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY); if (apiVersion.compareTo(languageVersion) > 0) {