Introduce a compiler X-flag to use the builder inference by default for all calls
^KT-48622 Fixed
This commit is contained in:
+11
@@ -374,6 +374,13 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
|||||||
)
|
)
|
||||||
var unrestrictedBuilderInference: Boolean by FreezableVar(false)
|
var unrestrictedBuilderInference: Boolean by FreezableVar(false)
|
||||||
|
|
||||||
|
@Argument(
|
||||||
|
value = "-Xenable-builder-inference",
|
||||||
|
description = "Use the builder inference by default, for all calls with lambdas which can't be resolved without it.\n" +
|
||||||
|
"The corresponding calls' declarations may not be marked with @BuilderInference."
|
||||||
|
)
|
||||||
|
var enableBuilderInference: Boolean by FreezableVar(false)
|
||||||
|
|
||||||
@Argument(
|
@Argument(
|
||||||
value = "-Xself-upper-bound-inference",
|
value = "-Xself-upper-bound-inference",
|
||||||
description = "Support inferring type arguments based on only self upper bounds of the corresponding type parameters"
|
description = "Support inferring type arguments based on only self upper bounds of the corresponding type parameters"
|
||||||
@@ -422,6 +429,10 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
|||||||
put(LanguageFeature.UnrestrictedBuilderInference, LanguageFeature.State.ENABLED)
|
put(LanguageFeature.UnrestrictedBuilderInference, LanguageFeature.State.ENABLED)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (enableBuilderInference) {
|
||||||
|
put(LanguageFeature.UseBuilderInferenceWithoutAnnotation, LanguageFeature.State.ENABLED)
|
||||||
|
}
|
||||||
|
|
||||||
if (selfUpperBoundInference) {
|
if (selfUpperBoundInference) {
|
||||||
put(LanguageFeature.TypeInferenceOnCallsWithSelfTypes, LanguageFeature.State.ENABLED)
|
put(LanguageFeature.TypeInferenceOnCallsWithSelfTypes, LanguageFeature.State.ENABLED)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -52,6 +52,8 @@ where advanced options include:
|
|||||||
-Xdump-fqname FqName of declaration that should be dumped
|
-Xdump-fqname FqName of declaration that should be dumped
|
||||||
-Xdump-perf=<path> Dump detailed performance statistics to the specified file
|
-Xdump-perf=<path> Dump detailed performance statistics to the specified file
|
||||||
-Xeffect-system Enable experimental language feature: effect system
|
-Xeffect-system Enable experimental language feature: effect system
|
||||||
|
-Xenable-builder-inference Use the builder inference by default, for all calls with lambdas which can't be resolved without it.
|
||||||
|
The corresponding calls' declarations may not be marked with @BuilderInference.
|
||||||
-Xexpect-actual-linker Enable experimental expect/actual linker
|
-Xexpect-actual-linker Enable experimental expect/actual linker
|
||||||
-Xexplicit-api={strict|warning|disable}
|
-Xexplicit-api={strict|warning|disable}
|
||||||
Force compiler to report errors on all public API declarations without explicit visibility or return type.
|
Force compiler to report errors on all public API declarations without explicit visibility or return type.
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
$TESTDATA_DIR$/builderInferenceByDefault.kt
|
||||||
|
-d
|
||||||
|
$TEMP_DIR$
|
||||||
|
-Xenable-builder-inference
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fun <K, V> buildMap(builderAction: MutableMap<K, V>.() -> Unit): Map<K, V> = mapOf()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val x = buildMap {
|
||||||
|
put("", "")
|
||||||
|
}
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
compiler/testData/cli/jvm/builderInferenceByDefault.kt:1:21: warning: parameter 'builderAction' is never used
|
||||||
|
fun <K, V> buildMap(builderAction: MutableMap<K, V>.() -> Unit): Map<K, V> = mapOf()
|
||||||
|
^
|
||||||
|
compiler/testData/cli/jvm/builderInferenceByDefault.kt:4:9: warning: variable 'x' is never used
|
||||||
|
val x = buildMap {
|
||||||
|
^
|
||||||
|
OK
|
||||||
+2
@@ -154,6 +154,8 @@ where advanced options include:
|
|||||||
-Xdump-fqname FqName of declaration that should be dumped
|
-Xdump-fqname FqName of declaration that should be dumped
|
||||||
-Xdump-perf=<path> Dump detailed performance statistics to the specified file
|
-Xdump-perf=<path> Dump detailed performance statistics to the specified file
|
||||||
-Xeffect-system Enable experimental language feature: effect system
|
-Xeffect-system Enable experimental language feature: effect system
|
||||||
|
-Xenable-builder-inference Use the builder inference by default, for all calls with lambdas which can't be resolved without it.
|
||||||
|
The corresponding calls' declarations may not be marked with @BuilderInference.
|
||||||
-Xexpect-actual-linker Enable experimental expect/actual linker
|
-Xexpect-actual-linker Enable experimental expect/actual linker
|
||||||
-Xexplicit-api={strict|warning|disable}
|
-Xexplicit-api={strict|warning|disable}
|
||||||
Force compiler to report errors on all public API declarations without explicit visibility or return type.
|
Force compiler to report errors on all public API declarations without explicit visibility or return type.
|
||||||
|
|||||||
@@ -106,6 +106,11 @@ public class CliTestGenerated extends AbstractCliTest {
|
|||||||
runTest("compiler/testData/cli/jvm/bothJvmIrAndOldBackend.args");
|
runTest("compiler/testData/cli/jvm/bothJvmIrAndOldBackend.args");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("builderInferenceByDefault.args")
|
||||||
|
public void testBuilderInferenceByDefault() throws Exception {
|
||||||
|
runTest("compiler/testData/cli/jvm/builderInferenceByDefault.args");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("classAndFileClassClash.args")
|
@TestMetadata("classAndFileClassClash.args")
|
||||||
public void testClassAndFileClassClash() throws Exception {
|
public void testClassAndFileClassClash() throws Exception {
|
||||||
runTest("compiler/testData/cli/jvm/classAndFileClassClash.args");
|
runTest("compiler/testData/cli/jvm/classAndFileClassClash.args");
|
||||||
|
|||||||
Reference in New Issue
Block a user