[CLI] Introduce compiler argument to suppress error about API version
...greater than language version. ^KT-63712
This commit is contained in:
committed by
Space Team
parent
22a6ffab6f
commit
1f30d076de
+1
@@ -70,6 +70,7 @@ fun copyCommonCompilerArguments(from: CommonCompilerArguments, to: CommonCompile
|
||||
to.selfUpperBoundInference = from.selfUpperBoundInference
|
||||
to.skipMetadataVersionCheck = from.skipMetadataVersionCheck
|
||||
to.skipPrereleaseCheck = from.skipPrereleaseCheck
|
||||
to.suppressApiVersionGreaterThanLanguageVersionError = from.suppressApiVersionGreaterThanLanguageVersionError
|
||||
to.suppressVersionWarnings = from.suppressVersionWarnings
|
||||
to.unrestrictedBuilderInference = from.unrestrictedBuilderInference
|
||||
to.useExperimental = from.useExperimental?.copyOf()
|
||||
|
||||
+20
-4
@@ -562,6 +562,18 @@ Use the 'warning' level to issue warnings instead of errors."""
|
||||
field = value
|
||||
}
|
||||
|
||||
// TODO(KT-56076): remove this argument after stdlib started to be built with 2.0
|
||||
@Argument(
|
||||
value = "-Xsuppress-api-version-greater-than-language-version-error",
|
||||
description = "Suppress error about API version greater than language version.\n" +
|
||||
"Warning: This is temporary solution (see KT-63712) intended to be used only for stdlib build."
|
||||
)
|
||||
var suppressApiVersionGreaterThanLanguageVersionError: Boolean = false
|
||||
set(value) {
|
||||
checkFrozen()
|
||||
field = value
|
||||
}
|
||||
|
||||
@Argument(
|
||||
value = "-Xextended-compiler-checks",
|
||||
description = """Enable additional compiler checks that might provide verbose diagnostic information for certain errors.
|
||||
@@ -911,10 +923,14 @@ The corresponding calls' declarations may not be marked with @BuilderInference."
|
||||
collector: MessageCollector
|
||||
) {
|
||||
if (apiVersion > ApiVersion.createByLanguageVersion(languageVersion)) {
|
||||
collector.report(
|
||||
CompilerMessageSeverity.ERROR,
|
||||
"-api-version (${apiVersion.versionString}) cannot be greater than -language-version (${languageVersion.versionString})"
|
||||
)
|
||||
if (!suppressApiVersionGreaterThanLanguageVersionError) {
|
||||
collector.report(
|
||||
CompilerMessageSeverity.ERROR,
|
||||
"-api-version (${apiVersion.versionString}) cannot be greater than -language-version (${languageVersion.versionString})"
|
||||
)
|
||||
}
|
||||
} else if (suppressApiVersionGreaterThanLanguageVersionError) {
|
||||
collector.report(WARNING, "Useless suppress -Xsuppress-api-version-greater-than-language-version-error")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -132,6 +132,9 @@ where advanced options include:
|
||||
-Xself-upper-bound-inference Support inferring type arguments from the self-type upper bounds of the corresponding type parameters.
|
||||
-Xskip-metadata-version-check Allow loading classes with bad metadata versions and pre-release classes.
|
||||
-Xskip-prerelease-check Allow loading pre-release classes.
|
||||
-Xsuppress-api-version-greater-than-language-version-error
|
||||
Suppress error about API version greater than language version.
|
||||
Warning: This is temporary solution (see KT-63712) intended to be used only for stdlib build.
|
||||
-Xsuppress-version-warnings Suppress warnings about outdated, inconsistent, or experimental language or API versions.
|
||||
-Xunrestricted-builder-inference
|
||||
Eliminate builder inference restrictions, for example by allowing type variables to be returned from builder inference calls.
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
$TESTDATA_DIR$/apiVersionGreaterThanLanguageSuppress.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-api-version
|
||||
2.0
|
||||
-language-version
|
||||
1.9
|
||||
-Xsuppress-api-version-greater-than-language-version-error
|
||||
@@ -0,0 +1,6 @@
|
||||
@SinceKotlin("2.0")
|
||||
fun new() {}
|
||||
|
||||
fun useNew() {
|
||||
new()
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,8 @@
|
||||
$TESTDATA_DIR$/apiVersionGreaterThanLanguageSuppress.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-api-version
|
||||
2.0
|
||||
-language-version
|
||||
2.0
|
||||
-Xsuppress-api-version-greater-than-language-version-error
|
||||
@@ -0,0 +1,2 @@
|
||||
warning: useless suppress -Xsuppress-api-version-greater-than-language-version-error
|
||||
OK
|
||||
+3
@@ -219,6 +219,9 @@ where advanced options include:
|
||||
-Xself-upper-bound-inference Support inferring type arguments from the self-type upper bounds of the corresponding type parameters.
|
||||
-Xskip-metadata-version-check Allow loading classes with bad metadata versions and pre-release classes.
|
||||
-Xskip-prerelease-check Allow loading pre-release classes.
|
||||
-Xsuppress-api-version-greater-than-language-version-error
|
||||
Suppress error about API version greater than language version.
|
||||
Warning: This is temporary solution (see KT-63712) intended to be used only for stdlib build.
|
||||
-Xsuppress-version-warnings Suppress warnings about outdated, inconsistent, or experimental language or API versions.
|
||||
-Xunrestricted-builder-inference
|
||||
Eliminate builder inference restrictions, for example by allowing type variables to be returned from builder inference calls.
|
||||
|
||||
@@ -215,6 +215,16 @@ public class CliTestGenerated extends AbstractCliTest {
|
||||
runTest("compiler/testData/cli/jvm/apiVersionGreaterThanLanguage.args");
|
||||
}
|
||||
|
||||
@TestMetadata("apiVersionGreaterThanLanguageSuppress.args")
|
||||
public void testApiVersionGreaterThanLanguageSuppress() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/apiVersionGreaterThanLanguageSuppress.args");
|
||||
}
|
||||
|
||||
@TestMetadata("apiVersionGreaterThanLanguageSuppressUseless.args")
|
||||
public void testApiVersionGreaterThanLanguageSuppressUseless() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/apiVersionGreaterThanLanguageSuppressUseless.args");
|
||||
}
|
||||
|
||||
@TestMetadata("apiVersionInvalid.args")
|
||||
public void testApiVersionInvalid() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/apiVersionInvalid.args");
|
||||
|
||||
Reference in New Issue
Block a user