Introduce separate compiler flag for unrestricted builder inference
This commit is contained in:
+10
@@ -365,6 +365,12 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
)
|
||||
var extendedCompilerChecks: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xunrestricted-builder-inference",
|
||||
description = "Eliminate builder inference restrictions like allowance of returning type variables of a builder inference call"
|
||||
)
|
||||
var unrestrictedBuilderInference: Boolean by FreezableVar(false)
|
||||
|
||||
open fun configureAnalysisFlags(collector: MessageCollector, languageVersion: LanguageVersion): MutableMap<AnalysisFlag<*>, Any> {
|
||||
return HashMap<AnalysisFlag<*>, Any>().apply {
|
||||
put(AnalysisFlags.skipMetadataVersionCheck, skipMetadataVersionCheck)
|
||||
@@ -394,6 +400,10 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
put(LanguageFeature.MultiPlatformProjects, LanguageFeature.State.ENABLED)
|
||||
}
|
||||
|
||||
if (unrestrictedBuilderInference) {
|
||||
put(LanguageFeature.UnrestrictedBuilderInference, LanguageFeature.State.ENABLED)
|
||||
}
|
||||
|
||||
if (newInference) {
|
||||
put(LanguageFeature.NewInference, LanguageFeature.State.ENABLED)
|
||||
put(LanguageFeature.SamConversionPerArgument, LanguageFeature.State.ENABLED)
|
||||
|
||||
+2
@@ -84,6 +84,8 @@ where advanced options include:
|
||||
-Xskip-metadata-version-check Allow to load classes with bad metadata version and pre-release classes
|
||||
-Xskip-prerelease-check Allow to load pre-release classes
|
||||
-Xsuppress-version-warnings Suppress warnings about outdated, inconsistent or experimental language or API versions
|
||||
-Xunrestricted-builder-inference
|
||||
Eliminate builder inference restrictions like allowance of returning type variables of a builder inference call
|
||||
-Xuse-experimental=<fq.name> Enable, but don't propagate usages of experimental API for marker annotation with the given fully qualified name
|
||||
-Xuse-fir Compile using Front-end IR. Warning: this feature is far from being production-ready
|
||||
-Xuse-fir-extended-checkers Use extended analysis mode based on Front-end IR. Warning: this feature is far from being production-ready
|
||||
|
||||
+2
@@ -194,6 +194,8 @@ where advanced options include:
|
||||
-Xskip-metadata-version-check Allow to load classes with bad metadata version and pre-release classes
|
||||
-Xskip-prerelease-check Allow to load pre-release classes
|
||||
-Xsuppress-version-warnings Suppress warnings about outdated, inconsistent or experimental language or API versions
|
||||
-Xunrestricted-builder-inference
|
||||
Eliminate builder inference restrictions like allowance of returning type variables of a builder inference call
|
||||
-Xuse-experimental=<fq.name> Enable, but don't propagate usages of experimental API for marker annotation with the given fully qualified name
|
||||
-Xuse-fir Compile using Front-end IR. Warning: this feature is far from being production-ready
|
||||
-Xuse-fir-extended-checkers Use extended analysis mode based on Front-end IR. Warning: this feature is far from being production-ready
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
$TESTDATA_DIR$/unrestrictedBuilderInference.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xunrestricted-builder-inference
|
||||
-Xopt-in=kotlin.RequiresOptIn
|
||||
@@ -0,0 +1,6 @@
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
fun main() {
|
||||
val x = buildMap {
|
||||
val y = put(1, "")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
compiler/testData/cli/jvm/unrestrictedBuilderInference.kt:3:9: warning: variable 'x' is never used
|
||||
val x = buildMap {
|
||||
^
|
||||
compiler/testData/cli/jvm/unrestrictedBuilderInference.kt:4:13: warning: variable 'y' is never used
|
||||
val y = put(1, "")
|
||||
^
|
||||
OK
|
||||
@@ -836,6 +836,11 @@ public class CliTestGenerated extends AbstractCliTest {
|
||||
runTest("compiler/testData/cli/jvm/unknownExtraFlags.args");
|
||||
}
|
||||
|
||||
@TestMetadata("unrestrictedBuilderInference.args")
|
||||
public void testUnrestrictedBuilderInference() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/unrestrictedBuilderInference.args");
|
||||
}
|
||||
|
||||
@TestMetadata("useDeclarationThatWasExperimentalWithoutExplicitImport.args")
|
||||
public void testUseDeclarationThatWasExperimentalWithoutExplicitImport() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/useDeclarationThatWasExperimentalWithoutExplicitImport.args");
|
||||
|
||||
Reference in New Issue
Block a user