Skip to content

Commit

Permalink
Remove --incompatible_disallow_conflicting_providers
Browse files Browse the repository at this point in the history
#5902

RELNOTES: Flag --incompatible_disallow_conflicting_providers is removed.
PiperOrigin-RevId: 228928434
  • Loading branch information
laurentlb authored and Copybara-Service committed Jan 11, 2019
1 parent 070c5ba commit b71ed30
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 103 deletions.
12 changes: 0 additions & 12 deletions site/docs/skylark/backward-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ Starlark Rules
* [Expand directories in Args](#expand-directories-in-args)
* [Disable late bound option defaults](#disable-late-bound-option-defaults)
* [Disallow `cfg = "data"`](#disallow-cfg--data)
* [Disallow conflicting providers](#disallow-conflicting-providers)

Objc

Expand Down Expand Up @@ -1054,17 +1053,6 @@ fail with an error.
* Tracking issue: [#6153](https://github.com/bazelbuild/bazel/issues/6153)


### Disallow conflicting providers

If set to true, disallow rule implementation functions from returning multiple
instances of the same type of provider. If false, only the last in the list will
be used.

* Flag: `incompatible_disallow_conflicting_providers`
* Default: `true`
* Tracking issue: [#5902](https://github.com/bazelbuild/bazel/issues/5902)


### Load label cannot cross package boundaries

Previously, the label argument to the `load` statement (the first argument) was
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,9 @@ private static void addProviders(
"The value of 'providers' should be a sequence of declared providers");
Provider.Key providerKey = declaredProvider.getProvider().getKey();
if (declaredProviders.put(providerKey, declaredProvider) != null) {
if (context.getSkylarkSemantics().incompatibleDisallowConflictingProviders()) {
context.getRuleContext()
.ruleError("Multiple conflicting returned providers with key " + providerKey);
}
context
.getRuleContext()
.ruleError("Multiple conflicting returned providers with key " + providerKey);
}
}
}
Expand All @@ -372,10 +371,9 @@ private static void addProviders(
+ "a sequence of declared providers");
Provider.Key providerKey = declaredProvider.getProvider().getKey();
if (declaredProviders.put(providerKey, declaredProvider) != null) {
if (context.getSkylarkSemantics().incompatibleDisallowConflictingProviders()) {
context.getRuleContext()
.ruleError("Multiple conflicting returned providers with key " + providerKey);
}
context
.getRuleContext()
.ruleError("Multiple conflicting returned providers with key " + providerKey);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,6 @@ public class SkylarkSemanticsOptions extends OptionsBase implements Serializable
)
public boolean incompatibleDisableObjcProviderResources;

@Option(
name = "incompatible_disallow_conflicting_providers",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.SKYLARK_SEMANTICS,
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help = "If set to true, disallow rule implementation functions from returning multiple "
+ "instances of the same type of provider. (If false, only the last in the list will be "
+ "used.)"
)
public boolean incompatibleDisallowConflictingProviders;

@Option(
name = "incompatible_disallow_data_transition",
defaultValue = "false",
Expand Down Expand Up @@ -499,6 +484,7 @@ public class SkylarkSemanticsOptions extends OptionsBase implements Serializable
)
public boolean internalSkylarkFlagTestCanary;


/** Constructs a {@link SkylarkSemantics} object corresponding to this set of option values. */
public SkylarkSemantics toSkylarkSemantics() {
return SkylarkSemantics.builder()
Expand All @@ -517,7 +503,6 @@ public SkylarkSemantics toSkylarkSemantics() {
.incompatibleDepsetUnion(incompatibleDepsetUnion)
.incompatibleDisableDeprecatedAttrParams(incompatibleDisableDeprecatedAttrParams)
.incompatibleDisableObjcProviderResources(incompatibleDisableObjcProviderResources)
.incompatibleDisallowConflictingProviders(incompatibleDisallowConflictingProviders)
.incompatibleDisallowDataTransition(incompatibleDisallowDataTransition)
.incompatibleDisallowDictPlus(incompatibleDisallowDictPlus)
.incompatibleDisallowFileType(incompatibleDisallowFileType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ public boolean flagValue(FlagIdentifier flagIdentifier) {

public abstract boolean incompatibleDisableObjcProviderResources();

public abstract boolean incompatibleDisallowConflictingProviders();

public abstract boolean incompatibleDisallowDataTransition();

public abstract boolean incompatibleDisallowDictPlus();
Expand Down Expand Up @@ -212,7 +210,6 @@ public static Builder builderWithDefaults() {
.incompatibleDepsetUnion(false)
.incompatibleDisableDeprecatedAttrParams(false)
.incompatibleDisableObjcProviderResources(false)
.incompatibleDisallowConflictingProviders(true)
.incompatibleDisallowDataTransition(false)
.incompatibleDisallowDictPlus(false)
.incompatibleDisallowFileType(false)
Expand Down Expand Up @@ -268,8 +265,6 @@ public abstract static class Builder {

public abstract Builder incompatibleDisableObjcProviderResources(boolean value);

public abstract Builder incompatibleDisallowConflictingProviders(boolean value);

public abstract Builder incompatibleDisallowDataTransition(boolean value);

public abstract Builder incompatibleDisallowDictPlus(boolean value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ private static SkylarkSemanticsOptions buildRandomOptions(Random rand) throws Ex
"--incompatible_depset_union=" + rand.nextBoolean(),
"--incompatible_disable_deprecated_attr_params=" + rand.nextBoolean(),
"--incompatible_disable_objc_provider_resources=" + rand.nextBoolean(),
"--incompatible_disallow_conflicting_providers=" + rand.nextBoolean(),
"--incompatible_disallow_data_transition=" + rand.nextBoolean(),
"--incompatible_disallow_dict_plus=" + rand.nextBoolean(),
"--incompatible_disallow_filetype=" + rand.nextBoolean(),
Expand Down Expand Up @@ -182,7 +181,6 @@ private static SkylarkSemantics buildRandomSemantics(Random rand) {
.incompatibleDepsetUnion(rand.nextBoolean())
.incompatibleDisableDeprecatedAttrParams(rand.nextBoolean())
.incompatibleDisableObjcProviderResources(rand.nextBoolean())
.incompatibleDisallowConflictingProviders(rand.nextBoolean())
.incompatibleDisallowDataTransition(rand.nextBoolean())
.incompatibleDisallowDictPlus(rand.nextBoolean())
.incompatibleDisallowFileType(rand.nextBoolean())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1329,38 +1329,8 @@ public void testRuleReturningUnwrappedDeclaredProvider() throws Exception {
assertThat(declaredProvider.getValue("x")).isEqualTo(1);
}

@Test
public void testConflictingProviderKeys_fromStruct_allowed() throws Exception {
setSkylarkSemanticsOptions("--incompatible_disallow_conflicting_providers=false");
scratch.file(
"test/extension.bzl",
"my_provider = provider()",
"other_provider = provider()",
"def _impl(ctx):",
" return struct(providers = [my_provider(x = 1), other_provider(), my_provider(x = 2)])",
"my_rule = rule(_impl)"
);

scratch.file(
"test/BUILD",
"load(':extension.bzl', 'my_rule')",
"my_rule(name = 'r')"
);

ConfiguredTarget configuredTarget = getConfiguredTarget("//test:r");
Provider.Key key =
new SkylarkProvider.SkylarkKey(
Label.create(configuredTarget.getLabel().getPackageIdentifier(), "extension.bzl"),
"my_provider");
StructImpl declaredProvider = (StructImpl) configuredTarget.get(key);
assertThat(declaredProvider).isNotNull();
assertThat(declaredProvider.getProvider().getKey()).isEqualTo(key);
assertThat(declaredProvider.getValue("x")).isEqualTo(2);
}

@Test
public void testConflictingProviderKeys_fromStruct_disallowed() throws Exception {
setSkylarkSemanticsOptions("--incompatible_disallow_conflicting_providers=true");
scratch.file(
"test/extension.bzl",
"my_provider = provider()",
Expand All @@ -1378,38 +1348,8 @@ public void testConflictingProviderKeys_fromStruct_disallowed() throws Exception
"my_rule(name = 'r')");
}

@Test
public void testConflictingProviderKeys_fromIterable_allowed() throws Exception {
setSkylarkSemanticsOptions("--incompatible_disallow_conflicting_providers=false");
scratch.file(
"test/extension.bzl",
"my_provider = provider()",
"other_provider = provider()",
"def _impl(ctx):",
" return [my_provider(x = 1), other_provider(), my_provider(x = 2)]",
"my_rule = rule(_impl)"
);

scratch.file(
"test/BUILD",
"load(':extension.bzl', 'my_rule')",
"my_rule(name = 'r')"
);

ConfiguredTarget configuredTarget = getConfiguredTarget("//test:r");
Provider.Key key =
new SkylarkProvider.SkylarkKey(
Label.create(configuredTarget.getLabel().getPackageIdentifier(), "extension.bzl"),
"my_provider");
StructImpl declaredProvider = (StructImpl) configuredTarget.get(key);
assertThat(declaredProvider).isNotNull();
assertThat(declaredProvider.getProvider().getKey()).isEqualTo(key);
assertThat(declaredProvider.getValue("x")).isEqualTo(2);
}

@Test
public void testConflictingProviderKeys_fromIterable_disallowed() throws Exception {
setSkylarkSemanticsOptions("--incompatible_disallow_conflicting_providers=true");
scratch.file(
"test/extension.bzl",
"my_provider = provider()",
Expand Down

0 comments on commit b71ed30

Please sign in to comment.