Enshrine that all ToolchainContexts in a toolchain collection have the same target platform so the toolchain collection should be able to directly access it.
Along the way, rm an unused method.
PiperOrigin-RevId: 333365303
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 99f52d9..47f687c 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
@@ -1219,16 +1219,11 @@
}
public boolean targetPlatformHasConstraint(ConstraintValueInfo constraintValue) {
- if (toolchainContexts == null
- || toolchainContexts.getDefaultToolchainContext().targetPlatform() == null) {
+ if (toolchainContexts == null || toolchainContexts.getTargetPlatform() == null) {
return false;
}
// All toolchain contexts should have the same target platform so we access via the default.
- return toolchainContexts
- .getDefaultToolchainContext()
- .targetPlatform()
- .constraints()
- .hasConstraintValue(constraintValue);
+ return toolchainContexts.getTargetPlatform().constraints().hasConstraintValue(constraintValue);
}
public ConstraintSemantics<RuleContext> getConstraintSemantics() {