Fix crash that happens when an aspect has the same implicit attribute as the rule that defines it.
RELNOTES: None.
PiperOrigin-RevId: 318456188
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java b/src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java
index 8760a00..6c68ae7 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java
@@ -895,4 +895,30 @@
aspect.getProvider(AspectApplyingToFiles.Provider.class);
assertThat(provider.getLabel()).isEqualTo(Label.parseAbsoluteUnchecked("//a:x_deploy.jar"));
}
+
+ @Test
+ public void sameConfiguredAttributeOnAspectAndRule() throws Exception {
+ scratch.file(
+ "a/a.bzl",
+ "def _a_impl(t, ctx):",
+ " return [DefaultInfo()]",
+ "def _r_impl(ctx):",
+ " return [DefaultInfo()]",
+ "a = aspect(",
+ " implementation = _a_impl,",
+ " attrs = {'_f': attr.label(",
+ " default = configuration_field(",
+ " fragment = 'cpp', name = 'cc_toolchain'))})",
+ "r = rule(",
+ " implementation = _r_impl,",
+ " attrs = {'_f': attr.label(",
+ " default = configuration_field(",
+ " fragment = 'cpp', name = 'cc_toolchain')),",
+ " 'dep': attr.label(aspects=[a])})");
+
+ scratch.file("a/BUILD", "load(':a.bzl', 'r')", "r(name='r')");
+
+ setRulesAndAspectsAvailableInTests(ImmutableList.of(), ImmutableList.of());
+ getConfiguredTarget("//a:r");
+ }
}