Skip to content

Commit bc1df91

Browse files
mai93copybara-github
authored andcommitted
For aspect evaluation, only check visibility of aspect's implicit dependencies
Move this check to also cover native aspects evaluation, otherwise it evaluates the visibility of the tools of the underlying target rule against the target itself. PiperOrigin-RevId: 573850253 Change-Id: I69beb6542128338fe859d2978d29018731fc1258
1 parent 0e1b3e2 commit bc1df91

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/main/java/com/google/devtools/build/lib/analysis/CommonPrerequisiteValidator.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ private void validateDirectPrerequisiteVisibility(
9999
return;
100100
}
101101

102+
// Only verify visibility of implicit dependencies of the current aspect.
103+
// Dependencies of other aspects as well as the rule itself are checked when they are
104+
// evaluated.
105+
Aspect mainAspect = context.getMainAspect();
106+
if (mainAspect != null) {
107+
if (!attribute.isImplicit()
108+
|| !mainAspect.getDefinition().getAttributes().containsKey(attrName)) {
109+
return;
110+
}
111+
}
112+
102113
// Determine if we should use the new visibility rules for tools.
103114
boolean toolCheckAtDefinition =
104115
context
@@ -118,16 +129,10 @@ private void validateDirectPrerequisiteVisibility(
118129
// from the location of the definition that declares the attribute. Only perform this check
119130
// for the current aspect.
120131
Label implicitDefinition = null;
121-
Aspect mainAspect = context.getMainAspect();
122132
if (mainAspect != null) {
123-
// Only verify visibility of implicit dependencies of the current aspect. Implicit
124-
// dependencies of other aspects as well as the rule itself are checked when they are
125-
// evaluated.
126-
if (mainAspect.getDefinition().getAttributes().containsKey(attrName)) {
127-
StarlarkAspectClass aspectClass = (StarlarkAspectClass) mainAspect.getAspectClass();
128-
// Never null since we already checked that the aspect is Starlark-defined.
129-
implicitDefinition = checkNotNull(aspectClass.getExtensionLabel());
130-
}
133+
StarlarkAspectClass aspectClass = (StarlarkAspectClass) mainAspect.getAspectClass();
134+
// Never null since we already checked that the aspect is Starlark-defined.
135+
implicitDefinition = checkNotNull(aspectClass.getExtensionLabel());
131136
} else {
132137
// Never null since we already checked that the rule is a Starlark rule.
133138
implicitDefinition =

0 commit comments

Comments
 (0)