Refactor LanguageVersionSettings.isApiVersionExplicit

Pass it in the CompilerConfiguration instead of LanguageVersionSettings.
This is better because LanguageVersionSettings is accessible everywhere
in front-end and back-end, and this flag should not be used there
This commit is contained in:
Alexander Udalov
2017-03-13 11:21:43 +03:00
parent 32826c1686
commit 34e131c928
5 changed files with 10 additions and 11 deletions
@@ -247,11 +247,15 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
// If only "-api-version" is specified, language version is assumed to be the latest
languageVersion = LanguageVersion.LATEST;
}
if (apiVersion == null) {
// If only "-language-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);
}
if (apiVersion.compareTo(languageVersion) > 0) {
configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report(
@@ -281,8 +285,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
languageVersion,
ApiVersion.createByLanguageVersion(apiVersion),
arguments.skipMetadataVersionCheck,
extraLanguageFeatures,
arguments.apiVersion != null
extraLanguageFeatures
)
);
}
@@ -29,6 +29,8 @@ public class CLIConfigurationKeys {
CompilerConfigurationKey.create("allow kotlin package");
public static final CompilerConfigurationKey<Boolean> REPORT_PERF =
CompilerConfigurationKey.create("report performance information");
public static final CompilerConfigurationKey<Boolean> IS_API_VERSION_EXPLICIT =
CompilerConfigurationKey.create("is API version explicit");
// Used in Eclipse plugin (see KotlinCLICompiler)
public static final CompilerConfigurationKey<CompilerJarLocator> COMPILER_JAR_LOCATOR =
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.cli.jvm
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
@@ -120,7 +121,7 @@ object JvmRuntimeVersionsConsistencyChecker {
val actualApi = ApiVersion.parse(actualRuntimeVersion.toString())
if (actualApi != null) {
val inferredApiVersion =
if (@Suppress("DEPRECATION") languageVersionSettings.isApiVersionExplicit)
if (configuration.getBoolean(CLIConfigurationKeys.IS_API_VERSION_EXPLICIT))
languageVersionSettings.apiVersion
else
// "minOf" is needed in case when API version was inferred from language version and it's older than actualApi.