Split language and api version lifetimes, restore apiVersion 1.3 support
KT-49007
This commit is contained in:
committed by
TeamCityServer
parent
47adc4fdaa
commit
ec5c06238d
+15
-26
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.cli.common.arguments
|
||||
@@ -50,7 +39,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
@get:Transient
|
||||
var autoAdvanceApiVersion: Boolean by FreezableVar(true)
|
||||
|
||||
@GradleOption(DefaultValues.LanguageVersions::class)
|
||||
@GradleOption(DefaultValues.ApiVersions::class)
|
||||
@Argument(
|
||||
value = "-api-version",
|
||||
valueDescription = "<version>",
|
||||
@@ -548,13 +537,13 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
|
||||
// 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)
|
||||
val apiVersion = parseVersion(collector, apiVersion, "API") ?: languageVersion
|
||||
val apiVersion = ApiVersion.createByLanguageVersion(parseVersion(collector, apiVersion, "API") ?: languageVersion)
|
||||
|
||||
checkApiVersionIsNotGreaterThenLanguageVersion(languageVersion, apiVersion, collector)
|
||||
|
||||
val languageVersionSettings = LanguageVersionSettingsImpl(
|
||||
languageVersion,
|
||||
ApiVersion.createByLanguageVersion(apiVersion),
|
||||
apiVersion,
|
||||
configureAnalysisFlags(collector, languageVersion),
|
||||
configureLanguageFeatures(collector)
|
||||
)
|
||||
@@ -570,10 +559,10 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
|
||||
private fun checkApiVersionIsNotGreaterThenLanguageVersion(
|
||||
languageVersion: LanguageVersion,
|
||||
apiVersion: LanguageVersion,
|
||||
apiVersion: ApiVersion,
|
||||
collector: MessageCollector
|
||||
) {
|
||||
if (apiVersion > languageVersion) {
|
||||
if (apiVersion > ApiVersion.createByLanguageVersion(languageVersion)) {
|
||||
collector.report(
|
||||
CompilerMessageSeverity.ERROR,
|
||||
"-api-version (${apiVersion.versionString}) cannot be greater than -language-version (${languageVersion.versionString})"
|
||||
@@ -591,14 +580,14 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkOutdatedVersions(language: LanguageVersion, api: LanguageVersion, collector: MessageCollector) {
|
||||
val (version, versionKind) = findOutdatedVersion(language, api) ?: return
|
||||
private fun checkOutdatedVersions(language: LanguageVersion, api: ApiVersion, collector: MessageCollector) {
|
||||
val (version, supportedVersion, versionKind) = findOutdatedVersion(language, api) ?: return
|
||||
when {
|
||||
version.isUnsupported -> {
|
||||
collector.report(
|
||||
CompilerMessageSeverity.ERROR,
|
||||
"${versionKind.text} version ${version.versionString} is no longer supported; " +
|
||||
"please, use version ${LanguageVersion.OLDEST_DEPRECATED.versionString} or greater."
|
||||
"please, use version ${supportedVersion!!.versionString} or greater."
|
||||
)
|
||||
}
|
||||
version.isDeprecated -> {
|
||||
@@ -611,12 +600,12 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun findOutdatedVersion(language: LanguageVersion, api: LanguageVersion): Pair<LanguageVersion, VersionKind>? {
|
||||
private fun findOutdatedVersion(language: LanguageVersion, api: ApiVersion): Triple<LanguageOrApiVersion, LanguageOrApiVersion?, VersionKind>? {
|
||||
return when {
|
||||
language.isUnsupported -> language to VersionKind.LANGUAGE
|
||||
api.isUnsupported -> api to VersionKind.API
|
||||
language.isDeprecated -> language to VersionKind.LANGUAGE
|
||||
api.isDeprecated -> api to VersionKind.API
|
||||
language.isUnsupported -> Triple(language, LanguageVersion.FIRST_SUPPORTED, VersionKind.LANGUAGE)
|
||||
api.isUnsupported -> Triple(api, ApiVersion.FIRST_SUPPORTED, VersionKind.API)
|
||||
language.isDeprecated -> Triple(language, null, VersionKind.LANGUAGE)
|
||||
api.isDeprecated -> Triple(api, null, VersionKind.API)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
+11
-13
@@ -1,23 +1,13 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.cli.common.arguments
|
||||
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.CALL
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.NO_CALL
|
||||
import org.jetbrains.kotlin.config.ApiVersion
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
|
||||
@@ -37,6 +27,14 @@ open class DefaultValues(val defaultValue: String, val possibleValues: List<Stri
|
||||
.map { "\"${it.description}\"" }
|
||||
)
|
||||
|
||||
object ApiVersions : DefaultValues(
|
||||
"null",
|
||||
LanguageVersion.values()
|
||||
.map(ApiVersion.Companion::createByLanguageVersion)
|
||||
.filterNot { it.isUnsupported }
|
||||
.map { "\"${it.description}\"" }
|
||||
)
|
||||
|
||||
object JvmTargetVersions : DefaultValues(
|
||||
"\"" + JvmTarget.DEFAULT.description + "\"",
|
||||
JvmTarget.values().map { "\"${it.description}\"" }
|
||||
|
||||
Reference in New Issue
Block a user