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
This commit is contained in:
@@ -165,19 +165,20 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> 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) {
|
||||
|
||||
Reference in New Issue
Block a user