Remove --incompatible_disallow_conflicting_providers
#5902
RELNOTES: Flag --incompatible_disallow_conflicting_providers is removed.
PiperOrigin-RevId: 228928434
diff --git a/site/docs/skylark/backward-compatibility.md b/site/docs/skylark/backward-compatibility.md
index 2416d8a..2b23305 100644
--- a/site/docs/skylark/backward-compatibility.md
+++ b/site/docs/skylark/backward-compatibility.md
@@ -53,7 +53,6 @@
* [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
@@ -1054,17 +1053,6 @@
* 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
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleConfiguredTargetUtil.java b/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleConfiguredTargetUtil.java
index df064a1..5e30d38 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleConfiguredTargetUtil.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleConfiguredTargetUtil.java
@@ -348,10 +348,9 @@
"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);
}
}
}
@@ -372,10 +371,9 @@
+ "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);
}
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsOptions.java b/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsOptions.java
index 206f061..721b43d 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsOptions.java
@@ -232,21 +232,6 @@
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",
documentationCategory = OptionDocumentationCategory.SKYLARK_SEMANTICS,
@@ -499,6 +484,7 @@
)
public boolean internalSkylarkFlagTestCanary;
+
/** Constructs a {@link SkylarkSemantics} object corresponding to this set of option values. */
public SkylarkSemantics toSkylarkSemantics() {
return SkylarkSemantics.builder()
@@ -517,7 +503,6 @@
.incompatibleDepsetUnion(incompatibleDepsetUnion)
.incompatibleDisableDeprecatedAttrParams(incompatibleDisableDeprecatedAttrParams)
.incompatibleDisableObjcProviderResources(incompatibleDisableObjcProviderResources)
- .incompatibleDisallowConflictingProviders(incompatibleDisallowConflictingProviders)
.incompatibleDisallowDataTransition(incompatibleDisallowDataTransition)
.incompatibleDisallowDictPlus(incompatibleDisallowDictPlus)
.incompatibleDisallowFileType(incompatibleDisallowFileType)
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemantics.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemantics.java
index 2086cb1..b7fbe0c 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemantics.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemantics.java
@@ -142,8 +142,6 @@
public abstract boolean incompatibleDisableObjcProviderResources();
- public abstract boolean incompatibleDisallowConflictingProviders();
-
public abstract boolean incompatibleDisallowDataTransition();
public abstract boolean incompatibleDisallowDictPlus();
@@ -212,7 +210,6 @@
.incompatibleDepsetUnion(false)
.incompatibleDisableDeprecatedAttrParams(false)
.incompatibleDisableObjcProviderResources(false)
- .incompatibleDisallowConflictingProviders(true)
.incompatibleDisallowDataTransition(false)
.incompatibleDisallowDictPlus(false)
.incompatibleDisallowFileType(false)
@@ -268,8 +265,6 @@
public abstract Builder incompatibleDisableObjcProviderResources(boolean value);
- public abstract Builder incompatibleDisallowConflictingProviders(boolean value);
-
public abstract Builder incompatibleDisallowDataTransition(boolean value);
public abstract Builder incompatibleDisallowDictPlus(boolean value);
diff --git a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
index d98f9e4..21cfc8e 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
@@ -137,7 +137,6 @@
"--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(),
@@ -182,7 +181,6 @@
.incompatibleDepsetUnion(rand.nextBoolean())
.incompatibleDisableDeprecatedAttrParams(rand.nextBoolean())
.incompatibleDisableObjcProviderResources(rand.nextBoolean())
- .incompatibleDisallowConflictingProviders(rand.nextBoolean())
.incompatibleDisallowDataTransition(rand.nextBoolean())
.incompatibleDisallowDictPlus(rand.nextBoolean())
.incompatibleDisallowFileType(rand.nextBoolean())
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java
index 8fd68bd..174fcaa 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java
@@ -1330,37 +1330,7 @@
}
@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()",
@@ -1379,37 +1349,7 @@
}
@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()",