Remove special handling of visibility dependencies in DependencyResolver.
This is done by allowing the analysis of a configured target with a null configuration to proceed a little further than before: we start the ConfiguredTargetFunction, but we short-circuit it as soon as we know that it won't work out.
RELNOTES: None.
PiperOrigin-RevId: 234465687
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
index ad2091f..508d56b 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
@@ -33,6 +33,7 @@
import com.google.devtools.build.lib.analysis.DependencyResolver.AttributeDependencyKind;
import com.google.devtools.build.lib.analysis.DependencyResolver.DependencyKind;
import com.google.devtools.build.lib.analysis.DependencyResolver.InconsistentAspectOrderException;
+import com.google.devtools.build.lib.analysis.EmptyConfiguredTarget;
import com.google.devtools.build.lib.analysis.PlatformSemantics;
import com.google.devtools.build.lib.analysis.TargetAndConfiguration;
import com.google.devtools.build.lib.analysis.ToolchainContext;
@@ -235,6 +236,21 @@
configuration = null;
}
+ if (target.isConfigurable() && configuredTargetKey.getConfigurationKey() == null) {
+ // We somehow ended up in a target that requires a non-null configuration as a dependency of
+ // one that requires a null configuration. This is always an error, but we need to analyze
+ // the dependencies of the latter target to realize that. Short-circuit the evaluation to
+ // avoid doing useless work and running code with a null configuration that's not prepared for
+ // it.
+ return new NonRuleConfiguredTargetValue(
+ new EmptyConfiguredTarget(target.getLabel(), null),
+ GeneratingActions.EMPTY,
+ transitivePackagesForPackageRootResolution == null
+ ? null
+ : transitivePackagesForPackageRootResolution.build(),
+ nonceVersion.get());
+ }
+
// This line is only needed for accurate error messaging. Say this target has a circular
// dependency with one of its deps. With this line, loading this target fails so Bazel
// associates the corresponding error with this target, as expected. Without this line,