Rename ToolchainContext to ResolvedToolchainContext.

Part of work on execution transitions, #7935.

Closes #7960.

PiperOrigin-RevId: 242172690
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredTargetFactory.java b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredTargetFactory.java
index 248ce28..4764352 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredTargetFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredTargetFactory.java
@@ -200,7 +200,7 @@
       ConfiguredTargetKey configuredTargetKey,
       OrderedSetMultimap<DependencyKind, ConfiguredTargetAndData> prerequisiteMap,
       ImmutableMap<Label, ConfigMatchingProvider> configConditions,
-      @Nullable ToolchainContext toolchainContext)
+      @Nullable ResolvedToolchainContext toolchainContext)
       throws InterruptedException, ActionConflictException {
     if (target instanceof Rule) {
       try {
@@ -286,7 +286,7 @@
       ConfiguredTargetKey configuredTargetKey,
       OrderedSetMultimap<DependencyKind, ConfiguredTargetAndData> prerequisiteMap,
       ImmutableMap<Label, ConfigMatchingProvider> configConditions,
-      @Nullable ToolchainContext toolchainContext)
+      @Nullable ResolvedToolchainContext toolchainContext)
       throws InterruptedException, ActionConflictException {
 
     // Visibility computation and checking is done for every rule.
@@ -473,7 +473,7 @@
       Aspect aspect,
       OrderedSetMultimap<DependencyKind, ConfiguredTargetAndData> prerequisiteMap,
       ImmutableMap<Label, ConfigMatchingProvider> configConditions,
-      @Nullable ToolchainContext toolchainContext,
+      @Nullable ResolvedToolchainContext toolchainContext,
       BuildConfiguration aspectConfiguration,
       BuildConfiguration hostConfiguration,
       ActionLookupValue.ActionLookupKey aspectKey)
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ResolvedToolchainContext.java b/src/main/java/com/google/devtools/build/lib/analysis/ResolvedToolchainContext.java
new file mode 100644
index 0000000..105a57d
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/analysis/ResolvedToolchainContext.java
@@ -0,0 +1,182 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.devtools.build.lib.analysis;
+
+import static java.util.stream.Collectors.joining;
+
+import com.google.auto.value.AutoValue;
+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.analysis.platform.ToolchainInfo;
+import com.google.devtools.build.lib.analysis.platform.ToolchainTypeInfo;
+import com.google.devtools.build.lib.cmdline.Label;
+import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
+import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
+import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
+import com.google.devtools.build.lib.events.Location;
+import com.google.devtools.build.lib.skylarkbuildapi.ToolchainContextApi;
+import com.google.devtools.build.lib.skylarkinterface.SkylarkPrinter;
+import com.google.devtools.build.lib.skylarkinterface.StarlarkContext;
+import com.google.devtools.build.lib.syntax.EvalException;
+import com.google.devtools.build.lib.syntax.EvalUtils;
+import java.util.Optional;
+import java.util.Set;
+import javax.annotation.Nullable;
+
+/**
+ * Represents the data needed for a specific target's use of toolchains and platforms, including
+ * specific {@link ToolchainInfo} providers for each required toolchain type.
+ */
+@AutoValue
+@Immutable
+@ThreadSafe
+public abstract class ResolvedToolchainContext implements ToolchainContextApi, ToolchainContext {
+
+  static Builder builder() {
+    return new AutoValue_ResolvedToolchainContext.Builder();
+  }
+
+  /** Builder interface to help create new instances of {@link ResolvedToolchainContext}. */
+  @AutoValue.Builder
+  interface Builder {
+    /** Sets a description of the target being used, for error messaging. */
+    Builder setTargetDescription(String targetDescription);
+
+    /** Sets the selected execution platform that these toolchains use. */
+    Builder setExecutionPlatform(PlatformInfo executionPlatform);
+
+    /** Sets the target platform that these toolchains generate output for. */
+    Builder setTargetPlatform(PlatformInfo targetPlatform);
+
+    /** Sets the toolchain types that were requested. */
+    Builder setRequiredToolchainTypes(Set<ToolchainTypeInfo> requiredToolchainTypes);
+
+    /** Sets the map from toolchain type to toolchain provider. */
+    Builder setToolchains(ImmutableMap<ToolchainTypeInfo, ToolchainInfo> toolchains);
+
+    /** Sets the template variables that these toolchains provide. */
+    Builder setTemplateVariableProviders(ImmutableList<TemplateVariableInfo> providers);
+
+    /** Sets the labels of the specific toolchains being used. */
+    Builder setResolvedToolchainLabels(ImmutableSet<Label> resolvedToolchainLabels);
+
+    /** Returns a new {@link ResolvedToolchainContext}. */
+    ResolvedToolchainContext build();
+  }
+
+  /** Returns a description of the target being used, for error messaging. */
+  abstract String targetDescription();
+
+  abstract ImmutableMap<ToolchainTypeInfo, ToolchainInfo> toolchains();
+
+  /** Returns the template variables that these toolchains provide. */
+  public abstract ImmutableList<TemplateVariableInfo> templateVariableProviders();
+
+  /**
+   * Returns the toolchain for the given type, or {@code null} if the toolchain type was not
+   * required in this context.
+   */
+  @Nullable
+  public ToolchainInfo forToolchainType(Label toolchainTypeLabel) {
+    Optional<ToolchainTypeInfo> toolchainType =
+        toolchains().keySet().stream()
+            .filter(info -> info.typeLabel().equals(toolchainTypeLabel))
+            .findFirst();
+    if (toolchainType.isPresent()) {
+      return forToolchainType(toolchainType.get());
+    } else {
+      return null;
+    }
+  }
+
+  @Nullable
+  public ToolchainInfo forToolchainType(ToolchainTypeInfo toolchainType) {
+    return toolchains().get(toolchainType);
+  }
+
+  @Override
+  public boolean isImmutable() {
+    return true;
+  }
+
+  @Override
+  public void repr(SkylarkPrinter printer) {
+    printer.append("<toolchain_context.resolved_labels: ");
+    printer.append(
+        toolchains().keySet().stream()
+            .map(ToolchainTypeInfo::typeLabel)
+            .map(Label::toString)
+            .collect(joining(", ")));
+    printer.append(">");
+  }
+
+  private Label transformKey(Object key, Location loc) throws EvalException {
+    if (key instanceof Label) {
+      return (Label) key;
+    } else if (key instanceof ToolchainTypeInfo) {
+      return ((ToolchainTypeInfo) key).typeLabel();
+    } else if (key instanceof String) {
+      Label toolchainType;
+      String rawLabel = (String) key;
+      try {
+        toolchainType = Label.parseAbsolute(rawLabel, ImmutableMap.of());
+      } catch (LabelSyntaxException e) {
+        throw new EvalException(
+            loc, String.format("Unable to parse toolchain %s: %s", rawLabel, e.getMessage()), e);
+      }
+      return toolchainType;
+    } else {
+      throw new EvalException(
+          loc,
+          String.format(
+              "Toolchains only supports indexing by toolchain type, got %s instead",
+              EvalUtils.getDataTypeName(key)));
+    }
+  }
+
+  @Override
+  public ToolchainInfo getIndex(Object key, Location loc, StarlarkContext context)
+      throws EvalException {
+    Label toolchainTypeLabel = transformKey(key, loc);
+
+    if (!containsKey(key, loc, context)) {
+      throw new EvalException(
+          loc,
+          String.format(
+              "In %s, toolchain type %s was requested but only types [%s] are configured",
+              targetDescription(),
+              toolchainTypeLabel,
+              requiredToolchainTypes().stream()
+                  .map(ToolchainTypeInfo::typeLabel)
+                  .map(Label::toString)
+                  .collect(joining(", "))));
+    }
+    return forToolchainType(toolchainTypeLabel);
+  }
+
+  @Override
+  public boolean containsKey(Object key, Location loc, StarlarkContext context)
+      throws EvalException {
+    Label toolchainTypeLabel = transformKey(key, loc);
+    Optional<Label> matching =
+        toolchains().keySet().stream()
+            .map(ToolchainTypeInfo::typeLabel)
+            .filter(label -> label.equals(toolchainTypeLabel))
+            .findAny();
+    return matching.isPresent();
+  }
+}
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 6b8b434..2737b69 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
@@ -186,7 +186,7 @@
   private final ConfigurationFragmentPolicy configurationFragmentPolicy;
   private final ImmutableList<Class<? extends BuildConfiguration.Fragment>> universalFragments;
   private final RuleErrorConsumer reporter;
-  @Nullable private final ToolchainContext toolchainContext;
+  @Nullable private final ResolvedToolchainContext toolchainContext;
   private final ConstraintSemantics constraintSemantics;
 
   private ActionOwner actionOwner;
@@ -205,7 +205,7 @@
       String ruleClassNameForLogging,
       ActionLookupValue.ActionLookupKey actionLookupKey,
       ImmutableMap<String, Attribute> aspectAttributes,
-      @Nullable ToolchainContext toolchainContext,
+      @Nullable ResolvedToolchainContext toolchainContext,
       ConstraintSemantics constraintSemantics) {
     super(
         builder.env,
@@ -1146,7 +1146,7 @@
   }
 
   @Nullable
-  public ToolchainContext getToolchainContext() {
+  public ResolvedToolchainContext getToolchainContext() {
     return toolchainContext;
   }
 
@@ -1490,7 +1490,7 @@
     private NestedSet<PackageGroupContents> visibility;
     private ImmutableMap<String, Attribute> aspectAttributes;
     private ImmutableList<Aspect> aspects;
-    private ToolchainContext toolchainContext;
+    private ResolvedToolchainContext toolchainContext;
     private ConstraintSemantics constraintSemantics;
 
     @VisibleForTesting
@@ -1597,8 +1597,8 @@
       return this;
     }
 
-    /** Sets the {@link ToolchainContext} used to access toolchains used by this rule. */
-    public Builder setToolchainContext(ToolchainContext toolchainContext) {
+    /** Sets the {@link ResolvedToolchainContext} used to access toolchains used by this rule. */
+    public Builder setToolchainContext(ResolvedToolchainContext toolchainContext) {
       this.toolchainContext = toolchainContext;
       return this;
     }
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ToolchainContext.java b/src/main/java/com/google/devtools/build/lib/analysis/ToolchainContext.java
index 401a34a..5753223 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/ToolchainContext.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/ToolchainContext.java
@@ -1,4 +1,4 @@
-// Copyright 2017 The Bazel Authors. All rights reserved.
+// Copyright 2019 The Bazel Authors. All rights reserved.
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -11,181 +11,25 @@
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
-
 package com.google.devtools.build.lib.analysis;
 
-import static java.util.stream.Collectors.joining;
-
-import com.google.auto.value.AutoValue;
-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.analysis.platform.ToolchainInfo;
 import com.google.devtools.build.lib.analysis.platform.ToolchainTypeInfo;
 import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
-import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
-import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
-import com.google.devtools.build.lib.events.Location;
-import com.google.devtools.build.lib.skylarkbuildapi.ToolchainContextApi;
-import com.google.devtools.build.lib.skylarkinterface.SkylarkPrinter;
-import com.google.devtools.build.lib.skylarkinterface.StarlarkContext;
-import com.google.devtools.build.lib.syntax.EvalException;
-import com.google.devtools.build.lib.syntax.EvalUtils;
-import java.util.Optional;
-import java.util.Set;
-import javax.annotation.Nullable;
 
 /** Represents the data needed for a specific target's use of toolchains and platforms. */
-@AutoValue
-@Immutable
-@ThreadSafe
-public abstract class ToolchainContext implements ToolchainContextApi {
-
-  static Builder builder() {
-    return new AutoValue_ToolchainContext.Builder();
-  }
-
-  /** Builder interface to help create new instances of {@link ToolchainContext}. */
-  @AutoValue.Builder
-  interface Builder {
-    /** Sets a description of the target being used, for error messaging. */
-    Builder setTargetDescription(String targetDescription);
-
-    /** Sets the selected execution platform that these toolchains use. */
-    Builder setExecutionPlatform(PlatformInfo executionPlatform);
-
-    /** Sets the target platform that these toolchains generate output for. */
-    Builder setTargetPlatform(PlatformInfo targetPlatform);
-
-    /** Sets the toolchain types that were requested. */
-    Builder setRequiredToolchainTypes(Set<ToolchainTypeInfo> requiredToolchainTypes);
-
-    /** Sets the map from toolchain type to toolchain provider. */
-    Builder setToolchains(ImmutableMap<ToolchainTypeInfo, ToolchainInfo> toolchains);
-
-    /** Sets the template variables that these toolchains provide. */
-    Builder setTemplateVariableProviders(ImmutableList<TemplateVariableInfo> providers);
-
-    /** Sets the labels of the specific toolchains being used. */
-    Builder setResolvedToolchainLabels(ImmutableSet<Label> resolvedToolchainLabels);
-
-    /** Returns a new {@link ToolchainContext}. */
-    ToolchainContext build();
-  }
-
-  /** Returns a description of the target being used, for error messaging. */
-  abstract String targetDescription();
+public interface ToolchainContext {
 
   /** Returns the selected execution platform that these toolchains use. */
-  public abstract PlatformInfo executionPlatform();
+  PlatformInfo executionPlatform();
 
   /** Returns the target platform that these toolchains generate output for. */
-  public abstract PlatformInfo targetPlatform();
+  PlatformInfo targetPlatform();
 
   /** Returns the toolchain types that were requested. */
-  public abstract ImmutableSet<ToolchainTypeInfo> requiredToolchainTypes();
-
-  abstract ImmutableMap<ToolchainTypeInfo, ToolchainInfo> toolchains();
-
-  /** Returns the template variables that these toolchains provide. */
-  public abstract ImmutableList<TemplateVariableInfo> templateVariableProviders();
+  ImmutableSet<ToolchainTypeInfo> requiredToolchainTypes();
 
   /** Returns the labels of the specific toolchains being used. */
-  public abstract ImmutableSet<Label> resolvedToolchainLabels();
-
-  /**
-   * Returns the toolchain for the given type, or {@code null} if the toolchain type was not
-   * required in this context.
-   */
-  @Nullable
-  public ToolchainInfo forToolchainType(Label toolchainTypeLabel) {
-    Optional<ToolchainTypeInfo> toolchainType =
-        toolchains().keySet().stream()
-            .filter(info -> info.typeLabel().equals(toolchainTypeLabel))
-            .findFirst();
-    if (toolchainType.isPresent()) {
-      return forToolchainType(toolchainType.get());
-    } else {
-      return null;
-    }
-  }
-
-  @Nullable
-  public ToolchainInfo forToolchainType(ToolchainTypeInfo toolchainType) {
-    return toolchains().get(toolchainType);
-  }
-
-  @Override
-  public boolean isImmutable() {
-    return true;
-  }
-
-  @Override
-  public void repr(SkylarkPrinter printer) {
-    printer.append("<toolchain_context.resolved_labels: ");
-    printer.append(
-        toolchains().keySet().stream()
-            .map(ToolchainTypeInfo::typeLabel)
-            .map(Label::toString)
-            .collect(joining(", ")));
-    printer.append(">");
-  }
-
-  private Label transformKey(Object key, Location loc) throws EvalException {
-    if (key instanceof Label) {
-      return (Label) key;
-    } else if (key instanceof ToolchainTypeInfo) {
-      return ((ToolchainTypeInfo) key).typeLabel();
-    } else if (key instanceof String) {
-      Label toolchainType;
-      String rawLabel = (String) key;
-      try {
-        toolchainType = Label.parseAbsolute(rawLabel, ImmutableMap.of());
-      } catch (LabelSyntaxException e) {
-        throw new EvalException(
-            loc, String.format("Unable to parse toolchain %s: %s", rawLabel, e.getMessage()), e);
-      }
-      return toolchainType;
-    } else {
-      throw new EvalException(
-          loc,
-          String.format(
-              "Toolchains only supports indexing by toolchain type, got %s instead",
-              EvalUtils.getDataTypeName(key)));
-    }
-  }
-
-  @Override
-  public ToolchainInfo getIndex(Object key, Location loc, StarlarkContext context)
-      throws EvalException {
-    Label toolchainTypeLabel = transformKey(key, loc);
-
-    if (!containsKey(key, loc, context)) {
-      throw new EvalException(
-          loc,
-          String.format(
-              "In %s, toolchain type %s was requested but only types [%s] are configured",
-              targetDescription(),
-              toolchainTypeLabel,
-              requiredToolchainTypes().stream()
-                  .map(ToolchainTypeInfo::typeLabel)
-                  .map(Label::toString)
-                  .collect(joining(", "))));
-    }
-    return forToolchainType(toolchainTypeLabel);
-  }
-
-  @Override
-  public boolean containsKey(Object key, Location loc, StarlarkContext context)
-      throws EvalException {
-    Label toolchainTypeLabel = transformKey(key, loc);
-    Optional<Label> matching =
-        toolchains().keySet().stream()
-            .map(ToolchainTypeInfo::typeLabel)
-            .filter(label -> label.equals(toolchainTypeLabel))
-            .findAny();
-    return matching.isPresent();
-  }
+  ImmutableSet<Label> resolvedToolchainLabels();
 }
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ToolchainResolver.java b/src/main/java/com/google/devtools/build/lib/analysis/ToolchainResolver.java
index 0ce1dd3..86b8601 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/ToolchainResolver.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/ToolchainResolver.java
@@ -123,7 +123,7 @@
    * report the specific toolchain targets to depend on, and those can be found using the typical
    * dependency machinery. Once dependencies, including toolchains, have been loaded, the {@link
    * UnloadedToolchainContext#load} method can be called to generate the final {@link
-   * ToolchainContext} to be used by the target.
+   * ResolvedToolchainContext} to be used by the target.
    *
    * <p>This makes several SkyFrame calls, particularly to {@link
    * com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction} (to load platforms and
@@ -504,14 +504,14 @@
     }
 
     /**
-     * Finishes preparing the {@link ToolchainContext} by finding the specific toolchain providers
-     * to be used for each toolchain type.
+     * Finishes preparing the {@link ResolvedToolchainContext} by finding the specific toolchain
+     * providers to be used for each toolchain type.
      */
-    public ToolchainContext load(Iterable<ConfiguredTargetAndData> toolchainTargets)
+    public ResolvedToolchainContext load(Iterable<ConfiguredTargetAndData> toolchainTargets)
         throws ToolchainException {
 
-      ToolchainContext.Builder toolchainContext =
-          ToolchainContext.builder()
+      ResolvedToolchainContext.Builder toolchainContext =
+          ResolvedToolchainContext.builder()
               .setTargetDescription(targetDescription())
               .setExecutionPlatform(executionPlatform())
               .setTargetPlatform(targetPlatform())
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
index 2194808..f83ea70 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
@@ -29,8 +29,8 @@
 import com.google.devtools.build.lib.analysis.DependencyResolver;
 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.ResolvedToolchainContext;
 import com.google.devtools.build.lib.analysis.TargetAndConfiguration;
-import com.google.devtools.build.lib.analysis.ToolchainContext;
 import com.google.devtools.build.lib.analysis.ToolchainResolver;
 import com.google.devtools.build.lib.analysis.ToolchainResolver.UnloadedToolchainContext;
 import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
@@ -461,7 +461,7 @@
       }
 
       // Load the requested toolchains into the ToolchainContext, now that we have dependencies.
-      ToolchainContext toolchainContext = null;
+      ResolvedToolchainContext toolchainContext = null;
       if (unloadedToolchainContext != null) {
         toolchainContext =
             unloadedToolchainContext.load(depValueMap.get(DependencyResolver.TOOLCHAIN_DEPENDENCY));
@@ -605,7 +605,7 @@
       ConfiguredTargetAndData associatedTarget,
       BuildConfiguration aspectConfiguration,
       ImmutableMap<Label, ConfigMatchingProvider> configConditions,
-      ToolchainContext toolchainContext,
+      ResolvedToolchainContext toolchainContext,
       OrderedSetMultimap<DependencyKind, ConfiguredTargetAndData> directDeps,
       @Nullable NestedSetBuilder<Package> transitivePackagesForPackageRootResolution)
       throws AspectFunctionException, InterruptedException {
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 c4c75b9..673108b 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
@@ -34,8 +34,8 @@
 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.ResolvedToolchainContext;
 import com.google.devtools.build.lib.analysis.TargetAndConfiguration;
-import com.google.devtools.build.lib.analysis.ToolchainContext;
 import com.google.devtools.build.lib.analysis.ToolchainResolver;
 import com.google.devtools.build.lib.analysis.ToolchainResolver.UnloadedToolchainContext;
 import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
@@ -338,7 +338,7 @@
       Preconditions.checkNotNull(depValueMap);
 
       // Load the requested toolchains into the ToolchainContext, now that we have dependencies.
-      ToolchainContext toolchainContext = null;
+      ResolvedToolchainContext toolchainContext = null;
       if (unloadedToolchainContext != null) {
         toolchainContext =
             unloadedToolchainContext.load(depValueMap.get(DependencyResolver.TOOLCHAIN_DEPENDENCY));
@@ -787,7 +787,7 @@
       ConfiguredTargetKey configuredTargetKey,
       OrderedSetMultimap<DependencyKind, ConfiguredTargetAndData> depValueMap,
       ImmutableMap<Label, ConfigMatchingProvider> configConditions,
-      @Nullable ToolchainContext toolchainContext,
+      @Nullable ResolvedToolchainContext toolchainContext,
       @Nullable NestedSetBuilder<Package> transitivePackagesForPackageRootResolution)
       throws ConfiguredTargetFunctionException, InterruptedException {
     StoredEventHandler events = new StoredEventHandler();
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java
index a090655..9e8ea6d 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java
@@ -43,7 +43,7 @@
 import com.google.devtools.build.lib.analysis.ConfiguredTarget;
 import com.google.devtools.build.lib.analysis.ConfiguredTargetFactory;
 import com.google.devtools.build.lib.analysis.DependencyResolver.DependencyKind;
-import com.google.devtools.build.lib.analysis.ToolchainContext;
+import com.google.devtools.build.lib.analysis.ResolvedToolchainContext;
 import com.google.devtools.build.lib.analysis.ViewCreationFailedException;
 import com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory;
 import com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory.BuildInfoKey;
@@ -757,7 +757,7 @@
       ConfiguredTargetKey configuredTargetKey,
       OrderedSetMultimap<DependencyKind, ConfiguredTargetAndData> prerequisiteMap,
       ImmutableMap<Label, ConfigMatchingProvider> configConditions,
-      @Nullable ToolchainContext toolchainContext)
+      @Nullable ResolvedToolchainContext toolchainContext)
       throws InterruptedException, ActionConflictException {
     Preconditions.checkState(
         enableAnalysis, "Already in execution phase %s %s", target, configuration);
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/ToolchainResolverTest.java b/src/test/java/com/google/devtools/build/lib/analysis/ToolchainResolverTest.java
index acb45d3..f262b26 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/ToolchainResolverTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/ToolchainResolverTest.java
@@ -468,7 +468,8 @@
     ConfiguredTargetAndData toolchain =
         getConfiguredTargetAndData(
             Label.parseAbsoluteUnchecked("//extra:extra_toolchain_linux_impl"), targetConfig);
-    ToolchainContext toolchainContext = unloadedToolchainContext.load(ImmutableList.of(toolchain));
+    ResolvedToolchainContext toolchainContext =
+        unloadedToolchainContext.load(ImmutableList.of(toolchain));
     assertThat(toolchainContext).isNotNull();
     assertThat(toolchainContext.forToolchainType(testToolchainType)).isNotNull();
     assertThat(toolchainContext.forToolchainType(testToolchainType).hasField("data")).isTrue();
@@ -557,7 +558,8 @@
     ConfiguredTargetAndData toolchain =
         getConfiguredTargetAndData(
             Label.parseAbsoluteUnchecked("//:variable_toolchain_impl"), targetConfig);
-    ToolchainContext toolchainContext = unloadedToolchainContext.load(ImmutableList.of(toolchain));
+    ResolvedToolchainContext toolchainContext =
+        unloadedToolchainContext.load(ImmutableList.of(toolchain));
     assertThat(toolchainContext).isNotNull();
     assertThat(toolchainContext.forToolchainType(variableToolchainType)).isNotNull();
     assertThat(toolchainContext.templateVariableProviders()).hasSize(1);
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java
index cd6bd25..0b7b547 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java
@@ -38,9 +38,9 @@
 import com.google.devtools.build.lib.analysis.DependencyResolver;
 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.ResolvedToolchainContext;
 import com.google.devtools.build.lib.analysis.RuleContext;
 import com.google.devtools.build.lib.analysis.TargetAndConfiguration;
-import com.google.devtools.build.lib.analysis.ToolchainContext;
 import com.google.devtools.build.lib.analysis.ToolchainResolver;
 import com.google.devtools.build.lib.analysis.ToolchainResolver.UnloadedToolchainContext;
 import com.google.devtools.build.lib.analysis.TopLevelArtifactContext;
@@ -493,7 +493,7 @@
             configuredTarget,
             configurations,
             unloadedToolchainContext.resolvedToolchainLabels());
-    ToolchainContext toolchainContext =
+    ResolvedToolchainContext toolchainContext =
         unloadedToolchainContext.load(prerequisiteMap.get(DependencyResolver.TOOLCHAIN_DEPENDENCY));
 
     return new RuleContext.Builder(