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/ToolchainCollection.java b/src/main/java/com/google/devtools/build/lib/analysis/ToolchainCollection.java
index 0ae7a33..a7457f8 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/ToolchainCollection.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/ToolchainCollection.java
@@ -18,9 +18,9 @@
 import com.google.auto.value.AutoValue;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
+import com.google.devtools.build.lib.analysis.platform.PlatformInfo;
 import com.google.devtools.build.lib.cmdline.Label;
 import java.util.HashMap;
 import java.util.Map;
@@ -63,6 +63,14 @@
     return getContextMap().keySet();
   }
 
+  /**
+   * This is safe because all toolchain context in a toolchain collection should have the same
+   * target platform
+   */
+  public PlatformInfo getTargetPlatform() {
+    return getDefaultToolchainContext().targetPlatform();
+  }
+
   @SuppressWarnings("unchecked")
   public ToolchainCollection<ToolchainContext> asToolchainContexts() {
     return (ToolchainCollection<ToolchainContext>) this;
@@ -73,16 +81,6 @@
     return new Builder<T>();
   }
 
-  /**
-   * Returns every instance of {@link ToolchainContext} that uses {@code resolvedToolchainLabel} as
-   * a resolved toolchain.
-   */
-  public ImmutableList<T> getContextsForResolvedToolchain(Label resolvedToolchainLabel) {
-    return getContextMap().values().stream()
-        .filter(tc -> tc.resolvedToolchainLabels().contains(resolvedToolchainLabel))
-        .collect(ImmutableList.toImmutableList());
-  }
-
   /** Builder for ToolchainCollection. */
   public static final class Builder<T extends ToolchainContext> {
     // This is not immutable so that we can check for duplicate keys easily.