diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java index acc3808795eb4a..dd8c19e8fb2da3 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java @@ -1711,17 +1711,20 @@ private ImmutableListMultimap createTar continue; } - if (attribute.isSilentRuleClassFilter()) { - Predicate filter = attribute.getAllowedRuleClassPredicate(); - for (ConfiguredTargetAndData configuredTarget : entry.getValue()) { - if (filter.apply(configuredTarget.getRuleClass())) { + Predicate filter = + attribute.isSilentRuleClassFilter() + ? attribute.getAllowedRuleClassPredicate() + : Predicates.alwaysTrue(); + + for (ConfiguredTargetAndData configuredTarget : entry.getValue()) { + if (filter.apply(configuredTarget.getRuleClass())) { + if (aspects.isEmpty() + || getMainAspect().getAspectClass().equals(entry.getKey().getOwningAspect())) { + // During aspects evaluation, only validate the dependencies of the main aspect. + // Dependencies of base aspects as well as the rule itself are checked when they + // are evaluated. validateDirectPrerequisite(attribute, configuredTarget); - mapBuilder.put(entry.getKey(), configuredTarget); } - } - } else { - for (ConfiguredTargetAndData configuredTarget : entry.getValue()) { - validateDirectPrerequisite(attribute, configuredTarget); mapBuilder.put(entry.getKey(), configuredTarget); } } diff --git a/src/test/java/com/google/devtools/build/lib/analysis/VisibilityTest.java b/src/test/java/com/google/devtools/build/lib/analysis/VisibilityTest.java index c725d6bbaa54cf..7a688adeb1cea1 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/VisibilityTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/VisibilityTest.java @@ -18,7 +18,6 @@ import static org.junit.Assert.assertThrows; import com.google.devtools.build.lib.analysis.util.AnalysisTestCase; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -274,9 +273,6 @@ public void testAspectImplicitDependencyCheckedAtDefinition_visible() throws Exc assertThat(hasErrors(getConfiguredTarget("//foo:target_with_aspects"))).isFalse(); } - @Ignore( - "TODO(b/206127051): The aspects path implicit dependencies with same name are incorrectly" - + " merged, enable this test when this is fixed.") @Test public void testAspectImplicitDependencyCheckedAtDefinition_visibleWithNameCollision() throws Exception {