Skip to content

Commit

Permalink
Convert flag --experimental_restrict_named_params to --incompatible_r…
Browse files Browse the repository at this point in the history
…estrict_named_params

This was always going to be an incompatible-style flag, but it was previously not fully implemented. Now it is.

Progress toward #8147 and #5010.

RELNOTES: Flag `--incompatible_restrict_named_params` is added. See #8147 for details.
PiperOrigin-RevId: 245428103
  • Loading branch information
c-parsons authored and copybara-github committed Apr 26, 2019
1 parent e189354 commit 6b3724f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,6 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl
+ "debugging.")
public boolean experimentalPlatformsApi;

// TODO(cparsons): Change this flag to --incompatible instead of --experimental when it is
// fully implemented.
@Option(
name = "experimental_restrict_named_params",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {OptionMetadataTag.EXPERIMENTAL},
help =
"If set to true, restricts a number of Starlark built-in function parameters to be "
+ "only specifiable positionally (and not by keyword).")
public boolean experimentalRestrictNamedParams;

// TODO(cparsons): Resolve and finalize the transition() API. The transition implementation
// function should accept two mandatory parameters, 'settings' and 'attr'.
@Option(
Expand Down Expand Up @@ -573,8 +560,6 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl
effectTags = {OptionEffectTag.UNKNOWN})
public boolean internalSkylarkFlagTestCanary;



@Option(
name = "incompatible_do_not_split_linking_cmdline",
defaultValue = "false",
Expand Down Expand Up @@ -606,6 +591,20 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl
+ "frameworks. See https://github.com/bazelbuild/bazel/issues/7944 for details.")
public boolean incompatibleObjcFrameworkCleanup;

@Option(
name = "incompatible_restrict_named_params",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help =
"If set to true, restricts a number of Starlark built-in function parameters to be "
+ "only specifiable positionally (and not by keyword).")
public boolean incompatibleRestrictNamedParams;

/** Constructs a {@link StarlarkSemantics} object corresponding to this set of option values. */
public StarlarkSemantics toSkylarkSemantics() {
return StarlarkSemantics.builder()
Expand All @@ -619,7 +618,6 @@ public StarlarkSemantics toSkylarkSemantics() {
.experimentalJavaCommonCreateProviderEnabledPackages(
experimentalJavaCommonCreateProviderEnabledPackages)
.experimentalPlatformsApi(experimentalPlatformsApi)
.experimentalRestrictNamedParams(experimentalRestrictNamedParams)
.experimentalStarlarkConfigTransitions(experimentalStarlarkConfigTransitions)
.incompatibleBzlDisallowLoadAfterStatement(incompatibleBzlDisallowLoadAfterStatement)
.incompatibleDepsetIsNotIterable(incompatibleDepsetIsNotIterable)
Expand Down Expand Up @@ -651,6 +649,7 @@ public StarlarkSemantics toSkylarkSemantics() {
.incompatibleObjcFrameworkCleanup(incompatibleObjcFrameworkCleanup)
.incompatibleRemapMainRepo(incompatibleRemapMainRepo)
.incompatibleRemoveNativeMavenJar(incompatibleRemoveNativeMavenJar)
.incompatibleRestrictNamedParams(incompatibleRestrictNamedParams)
.incompatibleStaticNameResolutionInBuildFiles(incompatibleStaticNameResolutionInBuildFiles)
.incompatibleStringJoinRequiresStrings(incompatibleStringJoinRequiresStrings)
.internalSkylarkFlagTestCanary(internalSkylarkFlagTestCanary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private static boolean isNamed(Param param, StarlarkSemantics starlarkSemantics)
if (param.named()) {
return true;
}
return param.legacyNamed() && !starlarkSemantics.experimentalRestrictNamedParams();
return param.legacyNamed() && !starlarkSemantics.incompatibleRestrictNamedParams();
}

/** @see Param#name() */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ public boolean flagValue(FlagIdentifier flagIdentifier) {

public abstract boolean experimentalPlatformsApi();

public abstract boolean experimentalRestrictNamedParams();

public abstract boolean experimentalStarlarkConfigTransitions();

public abstract boolean incompatibleBzlDisallowLoadAfterStatement();
Expand Down Expand Up @@ -192,6 +190,8 @@ public boolean flagValue(FlagIdentifier flagIdentifier) {

public abstract boolean incompatibleRemoveNativeMavenJar();

public abstract boolean incompatibleRestrictNamedParams();

public abstract boolean incompatibleStringJoinRequiresStrings();

public abstract boolean incompatibleStaticNameResolutionInBuildFiles();
Expand Down Expand Up @@ -222,7 +222,6 @@ public static Builder builderWithDefaults() {
.experimentalGoogleLegacyApi(false)
.experimentalJavaCommonCreateProviderEnabledPackages(ImmutableList.of())
.experimentalPlatformsApi(false)
.experimentalRestrictNamedParams(false)
.experimentalStarlarkConfigTransitions(false)
.incompatibleBzlDisallowLoadAfterStatement(true)
.incompatibleDepsetIsNotIterable(false)
Expand Down Expand Up @@ -252,6 +251,7 @@ public static Builder builderWithDefaults() {
.incompatibleObjcFrameworkCleanup(false)
.incompatibleRemapMainRepo(false)
.incompatibleRemoveNativeMavenJar(false)
.incompatibleRestrictNamedParams(false)
.incompatibleStaticNameResolutionInBuildFiles(false)
.incompatibleStringJoinRequiresStrings(false)
.internalSkylarkFlagTestCanary(false)
Expand All @@ -277,8 +277,6 @@ public abstract static class Builder {

public abstract Builder experimentalPlatformsApi(boolean value);

public abstract Builder experimentalRestrictNamedParams(boolean value);

public abstract Builder experimentalStarlarkConfigTransitions(boolean value);

public abstract Builder incompatibleBzlDisallowLoadAfterStatement(boolean value);
Expand Down Expand Up @@ -338,6 +336,8 @@ public abstract Builder incompatibleDisallowRuleExecutionPlatformConstraintsAllo

public abstract Builder incompatibleRemoveNativeMavenJar(boolean value);

public abstract Builder incompatibleRestrictNamedParams(boolean value);

public abstract Builder incompatibleStringJoinRequiresStrings(boolean value);

public abstract Builder incompatibleStaticNameResolutionInBuildFiles(boolean value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ private static StarlarkSemanticsOptions buildRandomOptions(Random rand) throws E
+ ","
+ rand.nextDouble(),
"--experimental_platforms_api=" + rand.nextBoolean(),
"--experimental_restrict_named_params=" + rand.nextBoolean(),
"--experimental_starlark_config_transitions=" + rand.nextBoolean(),
"--incompatible_bzl_disallow_load_after_statement=" + rand.nextBoolean(),
"--incompatible_depset_is_not_iterable=" + rand.nextBoolean(),
Expand Down Expand Up @@ -161,6 +160,7 @@ private static StarlarkSemanticsOptions buildRandomOptions(Random rand) throws E
"--incompatible_objc_framework_cleanup=" + rand.nextBoolean(),
"--incompatible_remap_main_repo=" + rand.nextBoolean(),
"--incompatible_remove_native_maven_jar=" + rand.nextBoolean(),
"--incompatible_restrict_named_params=" + rand.nextBoolean(),
"--incompatible_static_name_resolution_in_build_files=" + rand.nextBoolean(),
"--incompatible_string_join_requires_strings=" + rand.nextBoolean(),
"--internal_skylark_flag_test_canary=" + rand.nextBoolean(),
Expand All @@ -183,7 +183,6 @@ private static StarlarkSemantics buildRandomSemantics(Random rand) {
.experimentalJavaCommonCreateProviderEnabledPackages(
ImmutableList.of(String.valueOf(rand.nextDouble()), String.valueOf(rand.nextDouble())))
.experimentalPlatformsApi(rand.nextBoolean())
.experimentalRestrictNamedParams(rand.nextBoolean())
.experimentalStarlarkConfigTransitions(rand.nextBoolean())
.incompatibleBzlDisallowLoadAfterStatement(rand.nextBoolean())
.incompatibleDepsetIsNotIterable(rand.nextBoolean())
Expand Down Expand Up @@ -213,6 +212,7 @@ private static StarlarkSemantics buildRandomSemantics(Random rand) {
.incompatibleObjcFrameworkCleanup(rand.nextBoolean())
.incompatibleRemapMainRepo(rand.nextBoolean())
.incompatibleRemoveNativeMavenJar(rand.nextBoolean())
.incompatibleRestrictNamedParams(rand.nextBoolean())
.incompatibleStaticNameResolutionInBuildFiles(rand.nextBoolean())
.incompatibleStringJoinRequiresStrings(rand.nextBoolean())
.internalSkylarkFlagTestCanary(rand.nextBoolean())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ public void testLegacyNamed() throws Exception {

@Test
public void testExperimentalStarlarkConfig() throws Exception {
new SkylarkTest("--experimental_restrict_named_params")
new SkylarkTest("--incompatible_restrict_named_params")
.testIfErrorContains(
"parameter 'elements' may not be specified by name, "
+ "for call to method join(elements) of 'string'",
Expand Down

0 comments on commit 6b3724f

Please sign in to comment.