bazel syntax: rename SkylarkType to Depset.ElementType

Also in Depset:
- rename contentType to elementType
- doc comment tweaks
- inline ofValue
- add TODOs.

No functional changes. All other changes are mechanical.

PiperOrigin-RevId: 308044710
diff --git a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
index a7467a3..7fc1908 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
@@ -42,8 +42,8 @@
 import com.google.devtools.build.lib.skyframe.serialization.SerializationException;
 import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
 import com.google.devtools.build.lib.skylarkbuildapi.FileApi;
+import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.Printer;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.util.FileType;
 import com.google.devtools.build.lib.vfs.Path;
 import com.google.devtools.build.lib.vfs.PathFragment;
@@ -118,7 +118,7 @@
         CommandLineItem,
         SkyKey {
 
-  public static final SkylarkType TYPE = SkylarkType.of(Artifact.class);
+  public static final Depset.ElementType TYPE = Depset.ElementType.of(Artifact.class);
 
   /** Compares artifact according to their exec paths. Sorts null values first. */
   @SuppressWarnings("ReferenceEquality") // "a == b" is an optimization
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java b/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java
index d9d5dc9..889c56a 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java
@@ -39,7 +39,6 @@
 import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.Location;
 import com.google.devtools.build.lib.syntax.Printer;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.util.Fingerprint;
 import com.google.devtools.build.lib.vfs.PathFragment;
 import java.io.BufferedReader;
@@ -118,7 +117,7 @@
   @VisibleForSerialization
   static final class SymlinkEntry implements SymlinkEntryApi {
 
-    static final SkylarkType TYPE = SkylarkType.of(SymlinkEntry.class);
+    static final Depset.ElementType TYPE = Depset.ElementType.of(SymlinkEntry.class);
 
     private final PathFragment path;
     private final Artifact artifact;
@@ -364,7 +363,7 @@
 
   @Override
   public Depset /*<String>*/ getEmptyFilenamesForStarlark() {
-    return Depset.of(SkylarkType.STRING, getEmptyFilenames());
+    return Depset.of(Depset.ElementType.STRING, getEmptyFilenames());
   }
 
   public NestedSet<String> getEmptyFilenames() {
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/test/AnalysisFailure.java b/src/main/java/com/google/devtools/build/lib/analysis/test/AnalysisFailure.java
index 4a7066a..1c40032 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/test/AnalysisFailure.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/test/AnalysisFailure.java
@@ -16,8 +16,8 @@
 
 import com.google.devtools.build.lib.cmdline.Label;
 import com.google.devtools.build.lib.skylarkbuildapi.test.AnalysisFailureApi;
+import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.Printer;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 
 /**
  * Encapsulates information about an analysis-phase error which would have occurred during a build.
@@ -25,7 +25,7 @@
 public class AnalysisFailure implements AnalysisFailureApi {
 
   /** The Starlark type symbol for AnalysisFailure values. */
-  public static final SkylarkType TYPE = SkylarkType.of(AnalysisFailure.class);
+  public static final Depset.ElementType TYPE = Depset.ElementType.of(AnalysisFailure.class);
 
   private final Label label;
   private final String message;
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/Label.java b/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
index e4154be..6e40a4e 100644
--- a/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
+++ b/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
@@ -28,8 +28,8 @@
 import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
+import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.Printer;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.syntax.StarlarkSemantics;
 import com.google.devtools.build.lib.syntax.StarlarkThread;
 import com.google.devtools.build.lib.syntax.StarlarkValue;
@@ -62,7 +62,7 @@
     implements Comparable<Label>, Serializable, StarlarkValue, SkyKey, CommandLineItem {
 
   /** The Starlark type symbol for Label values. */
-  public static final SkylarkType TYPE = SkylarkType.of(Label.class);
+  public static final Depset.ElementType TYPE = Depset.ElementType.of(Label.class);
 
   /**
    * Package names that aren't made relative to the current repository because they mean special
diff --git a/src/main/java/com/google/devtools/build/lib/packages/SelectorList.java b/src/main/java/com/google/devtools/build/lib/packages/SelectorList.java
index 7e0799d..9263b8a 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/SelectorList.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/SelectorList.java
@@ -18,11 +18,11 @@
 import com.google.common.collect.Iterables;
 import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
+import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.Dict;
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.HasBinary;
 import com.google.devtools.build.lib.syntax.Printer;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.syntax.Starlark;
 import com.google.devtools.build.lib.syntax.StarlarkValue;
 import com.google.devtools.build.lib.syntax.TokenKind;
@@ -152,9 +152,9 @@
 
   private static String getTypeName(Object x) {
     if (x instanceof SelectorList) {
-      return "select of " + SkylarkType.of(((SelectorList) x).getType());
+      return "select of " + Depset.ElementType.of(((SelectorList) x).getType());
     } else if (x instanceof SelectorValue) {
-      return "select of " + SkylarkType.of(((SelectorValue) x).getType());
+      return "select of " + Depset.ElementType.of(((SelectorValue) x).getType());
     } else {
       return Starlark.type(x);
     }
diff --git a/src/main/java/com/google/devtools/build/lib/packages/SelectorValue.java b/src/main/java/com/google/devtools/build/lib/packages/SelectorValue.java
index e61d6e8..60e9b76 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/SelectorValue.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/SelectorValue.java
@@ -64,7 +64,6 @@
     return dictionary;
   }
 
-  // TODO(adonovan): use SkylarkType not Class, like Depset.
   Class<?> getType() {
     return type;
   }
diff --git a/src/main/java/com/google/devtools/build/lib/packages/SkylarkInfo.java b/src/main/java/com/google/devtools/build/lib/packages/SkylarkInfo.java
index 70e3a4c..9958a7f 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/SkylarkInfo.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/SkylarkInfo.java
@@ -19,11 +19,11 @@
 import com.google.common.collect.ImmutableCollection;
 import com.google.common.collect.ImmutableList;
 import com.google.devtools.build.lib.syntax.ClassObject;
+import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.EvalUtils;
 import com.google.devtools.build.lib.syntax.HasBinary;
 import com.google.devtools.build.lib.syntax.Location;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.syntax.Starlark;
 import com.google.devtools.build.lib.syntax.TokenKind;
 import java.util.ArrayList;
@@ -35,7 +35,7 @@
 /** An Info (provider instance) for providers defined in Starlark. */
 public final class SkylarkInfo extends StructImpl implements HasBinary, ClassObject {
 
-  public static final SkylarkType TYPE = SkylarkType.of(SkylarkInfo.class);
+  public static final Depset.ElementType TYPE = Depset.ElementType.of(SkylarkInfo.class);
 
   // For a n-element info, the table contains n key strings, sorted,
   // followed by the n corresponding legal Starlark values.
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidIdlProvider.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidIdlProvider.java
index 52aea06..828b821 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidIdlProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidIdlProvider.java
@@ -22,7 +22,6 @@
 import com.google.devtools.build.lib.skylarkbuildapi.android.AndroidIdlProviderApi;
 import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.EvalException;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 
 /**
  * Configured targets implementing this provider can contribute Android IDL information to the
@@ -53,7 +52,7 @@
 
   @Override
   public Depset /*<String>*/ getTransitiveIdlImportRootsForStarlark() {
-    return Depset.of(SkylarkType.STRING, transitiveIdlImportRoots);
+    return Depset.of(Depset.ElementType.STRING, transitiveIdlImportRoots);
   }
 
   NestedSet<String> getTransitiveIdlImportRoots() {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ParsedAndroidAssets.java b/src/main/java/com/google/devtools/build/lib/rules/android/ParsedAndroidAssets.java
index 41f04b0..d86cb2a 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/ParsedAndroidAssets.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/ParsedAndroidAssets.java
@@ -16,14 +16,14 @@
 import com.google.devtools.build.lib.actions.Artifact;
 import com.google.devtools.build.lib.cmdline.Label;
 import com.google.devtools.build.lib.skylarkbuildapi.android.ParsedAndroidAssetsApi;
-import com.google.devtools.build.lib.syntax.SkylarkType;
+import com.google.devtools.build.lib.syntax.Depset;
 import java.util.Objects;
 import javax.annotation.Nullable;
 
 /** Parsed Android assets which can be merged together with assets from dependencies. */
 public class ParsedAndroidAssets extends AndroidAssets implements ParsedAndroidAssetsApi {
 
-  public static final SkylarkType TYPE = SkylarkType.of(ParsedAndroidAssets.class);
+  public static final Depset.ElementType TYPE = Depset.ElementType.of(ParsedAndroidAssets.class);
 
   private final Artifact symbols;
   @Nullable private final Artifact compiledSymbols;
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ValidatedAndroidResources.java b/src/main/java/com/google/devtools/build/lib/rules/android/ValidatedAndroidResources.java
index 72bb71a2..f358436 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/ValidatedAndroidResources.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/ValidatedAndroidResources.java
@@ -17,8 +17,8 @@
 import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException;
 import com.google.devtools.build.lib.packages.RuleErrorConsumer;
 import com.google.devtools.build.lib.skylarkbuildapi.android.ValidatedAndroidDataApi;
+import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.Sequence;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.syntax.StarlarkList;
 import java.util.Objects;
 import java.util.Optional;
@@ -28,7 +28,8 @@
 public class ValidatedAndroidResources extends MergedAndroidResources
     implements ValidatedAndroidDataApi<Artifact, AndroidResourcesInfo> {
 
-  public static final SkylarkType TYPE = SkylarkType.of(ValidatedAndroidResources.class);
+  public static final Depset.ElementType TYPE =
+      Depset.ElementType.of(ValidatedAndroidResources.class);
 
   private final Artifact rTxt;
   private final Artifact sourceJar;
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationContext.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationContext.java
index ebffc0b..93c0d3b 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationContext.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationContext.java
@@ -39,7 +39,6 @@
 import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization;
 import com.google.devtools.build.lib.skylarkbuildapi.cpp.CcCompilationContextApi;
 import com.google.devtools.build.lib.syntax.Depset;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.syntax.StarlarkList;
 import com.google.devtools.build.lib.util.Pair;
 import com.google.devtools.build.lib.vfs.PathFragment;
@@ -141,13 +140,14 @@
 
   @Override
   public Depset getSkylarkDefines() {
-    return Depset.of(SkylarkType.STRING, getDefines());
+    return Depset.of(Depset.ElementType.STRING, getDefines());
   }
 
   @Override
   public Depset getSkylarkNonTransitiveDefines() {
     return Depset.of(
-        SkylarkType.STRING, NestedSetBuilder.wrap(Order.STABLE_ORDER, getNonTransitiveDefines()));
+        Depset.ElementType.STRING,
+        NestedSetBuilder.wrap(Order.STABLE_ORDER, getNonTransitiveDefines()));
   }
 
   @Override
@@ -168,7 +168,7 @@
   @Override
   public Depset getSkylarkSystemIncludeDirs() {
     return Depset.of(
-        SkylarkType.STRING,
+        Depset.ElementType.STRING,
         NestedSetBuilder.wrap(
             Order.STABLE_ORDER,
             getSystemIncludeDirs().stream()
@@ -179,7 +179,7 @@
   @Override
   public Depset getSkylarkFrameworkIncludeDirs() {
     return Depset.of(
-        SkylarkType.STRING,
+        Depset.ElementType.STRING,
         NestedSetBuilder.wrap(
             Order.STABLE_ORDER,
             getFrameworkIncludeDirs().stream()
@@ -190,7 +190,7 @@
   @Override
   public Depset getSkylarkIncludeDirs() {
     return Depset.of(
-        SkylarkType.STRING,
+        Depset.ElementType.STRING,
         NestedSetBuilder.wrap(
             Order.STABLE_ORDER,
             getIncludeDirs().stream()
@@ -201,7 +201,7 @@
   @Override
   public Depset getSkylarkQuoteIncludeDirs() {
     return Depset.of(
-        SkylarkType.STRING,
+        Depset.ElementType.STRING,
         NestedSetBuilder.wrap(
             Order.STABLE_ORDER,
             getQuoteIncludeDirs().stream()
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingContext.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingContext.java
index aa8d09f..0a000b5 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingContext.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingContext.java
@@ -33,7 +33,6 @@
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.Printer;
 import com.google.devtools.build.lib.syntax.Sequence;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.syntax.Starlark;
 import com.google.devtools.build.lib.syntax.StarlarkList;
 import com.google.devtools.build.lib.syntax.StarlarkSemantics;
@@ -164,7 +163,7 @@
   @Immutable
   public static class LinkerInput implements LinkerInputApi<LibraryToLink, Artifact> {
 
-    public static final SkylarkType TYPE = SkylarkType.of(LinkerInput.class);
+    public static final Depset.ElementType TYPE = Depset.ElementType.of(LinkerInput.class);
 
     // Identifies which target created the LinkerInput. It doesn't have to be unique between
     // LinkerInputs.
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/LibraryToLink.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/LibraryToLink.java
index 15c227f..9c04c22 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/LibraryToLink.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/LibraryToLink.java
@@ -24,9 +24,9 @@
 import com.google.devtools.build.lib.collect.nestedset.NestedSet;
 import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
 import com.google.devtools.build.lib.skylarkbuildapi.cpp.LibraryToLinkApi;
+import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.Printer;
 import com.google.devtools.build.lib.syntax.Sequence;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.syntax.StarlarkList;
 import java.util.List;
 import javax.annotation.Nullable;
@@ -44,7 +44,7 @@
 @CopyAnnotations
 public abstract class LibraryToLink implements LibraryToLinkApi<Artifact> {
 
-  public static final SkylarkType TYPE = SkylarkType.of(LibraryToLink.class);
+  public static final Depset.ElementType TYPE = Depset.ElementType.of(LibraryToLink.class);
 
   public Artifact getDynamicLibraryForRuntimeOrNull(boolean linkingStatically) {
     if (getDynamicLibrary() == null) {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java
index 603665d..648fc38 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java
@@ -40,7 +40,6 @@
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.Location;
 import com.google.devtools.build.lib.syntax.Sequence;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.syntax.Starlark;
 import com.google.devtools.build.lib.syntax.StarlarkList;
 import com.google.devtools.build.lib.syntax.StarlarkThread;
@@ -366,7 +365,7 @@
   @Override
   public Depset /*<Label>*/ getTransitiveExports() {
     return Depset.of(
-        SkylarkType.of(Label.class),
+        Depset.ElementType.of(Label.class),
         getProviderAsNestedSet(
             JavaExportsProvider.class, JavaExportsProvider::getTransitiveExports));
   }
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleDynamicFrameworkInfo.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleDynamicFrameworkInfo.java
index ee34560..8c193bb 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleDynamicFrameworkInfo.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleDynamicFrameworkInfo.java
@@ -21,7 +21,6 @@
 import com.google.devtools.build.lib.packages.NativeProvider;
 import com.google.devtools.build.lib.skylarkbuildapi.apple.AppleDynamicFrameworkInfoApi;
 import com.google.devtools.build.lib.syntax.Depset;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import javax.annotation.Nullable;
 
 /**
@@ -78,7 +77,7 @@
 
   @Override
   public Depset /*<String>*/ getDynamicFrameworkDirs() {
-    return Depset.of(SkylarkType.STRING, dynamicFrameworkDirs);
+    return Depset.of(Depset.ElementType.STRING, dynamicFrameworkDirs);
   }
 
   @Override
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java
index fc869b9..b7428aa 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java
@@ -43,7 +43,6 @@
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.EvalUtils;
 import com.google.devtools.build.lib.syntax.Sequence;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.syntax.StarlarkList;
 import com.google.devtools.build.lib.syntax.StarlarkSemantics;
 import com.google.devtools.build.lib.vfs.PathFragment;
@@ -406,7 +405,7 @@
     // framework search path, so the best we can do is to append a fake ".framework" directory.
     // This at least preserves the behavior when the field is used for its intended purpose.
     return Depset.of(
-        SkylarkType.STRING,
+        Depset.ElementType.STRING,
         NestedSetBuilder.wrap(
             Order.STABLE_ORDER,
             frameworkInclude().stream()
@@ -445,7 +444,7 @@
   @Override
   public Depset /*<String>*/ includeForStarlark() {
     return Depset.of(
-        SkylarkType.STRING,
+        Depset.ElementType.STRING,
         NestedSetBuilder.wrap(
             Order.STABLE_ORDER,
             include().stream()
@@ -464,7 +463,7 @@
   @Override
   public Depset /*<String>*/ strictIncludeForStarlark() {
     return Depset.of(
-        SkylarkType.STRING,
+        Depset.ElementType.STRING,
         NestedSetBuilder.wrap(
             Order.STABLE_ORDER,
             getStrictDependencyIncludes().stream()
@@ -522,7 +521,7 @@
 
   @Override
   public Depset /*<String>*/ linkopt() {
-    return Depset.of(SkylarkType.STRING, get(LINKOPT));
+    return Depset.of(Depset.ElementType.STRING, get(LINKOPT));
   }
 
   @Override
@@ -557,7 +556,7 @@
 
   @Override
   public Depset /*<String>*/ sdkDylib() {
-    return Depset.of(SkylarkType.STRING, get(SDK_DYLIB));
+    return Depset.of(Depset.ElementType.STRING, get(SDK_DYLIB));
   }
 
   @Override
@@ -932,7 +931,7 @@
 
   @Override
   public Depset /*<String>*/ dynamicFrameworkNamesForStarlark() {
-    return Depset.of(SkylarkType.STRING, dynamicFrameworkNames());
+    return Depset.of(Depset.ElementType.STRING, dynamicFrameworkNames());
   }
 
   NestedSet<String> dynamicFrameworkNames() {
@@ -941,7 +940,7 @@
 
   @Override
   public Depset /*<String>*/ dynamicFrameworkPathsForStarlark() {
-    return Depset.of(SkylarkType.STRING, dynamicFrameworkPaths());
+    return Depset.of(Depset.ElementType.STRING, dynamicFrameworkPaths());
   }
 
   NestedSet<String> dynamicFrameworkPaths() {
@@ -950,7 +949,7 @@
 
   @Override
   public Depset /*<String>*/ staticFrameworkNamesForStarlark() {
-    return Depset.of(SkylarkType.STRING, staticFrameworkNames());
+    return Depset.of(Depset.ElementType.STRING, staticFrameworkNames());
   }
 
   NestedSet<String> staticFrameworkNames() {
@@ -959,7 +958,7 @@
 
   @Override
   public Depset /*<String>*/ staticFrameworkPathsForStarlark() {
-    return Depset.of(SkylarkType.STRING, staticFrameworkPaths());
+    return Depset.of(Depset.ElementType.STRING, staticFrameworkPaths());
   }
 
   NestedSet<String> staticFrameworkPaths() {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProviderSkylarkConverters.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProviderSkylarkConverters.java
index 25a18fb..b93154d 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProviderSkylarkConverters.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProviderSkylarkConverters.java
@@ -25,7 +25,6 @@
 import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.EvalUtils;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.vfs.PathFragment;
 
 /** A utility class for converting ObjcProvider values between java and Starlark representation. */
@@ -60,7 +59,7 @@
     for (PathFragment path : pathFragments.toList()) {
       result.add(path.getSafePathString());
     }
-    return Depset.of(SkylarkType.STRING, result.build());
+    return Depset.of(Depset.ElementType.STRING, result.build());
   }
 
   /** A converter for ObjcProvider values. */
@@ -77,7 +76,7 @@
 
     @Override
     public Object valueForSkylark(Key<?> javaKey, NestedSet<?> javaValue) {
-      SkylarkType type = SkylarkType.of(javaKey.getType());
+      Depset.ElementType type = Depset.ElementType.of(javaKey.getType());
       return Depset.of(type, javaValue);
     }
 
@@ -118,7 +117,7 @@
       for (SdkFramework framework : ((NestedSet<SdkFramework>) javaValue).toList()) {
         result.add(framework.getName());
       }
-      return Depset.of(SkylarkType.STRING, result.build());
+      return Depset.of(Depset.ElementType.STRING, result.build());
     }
 
     @Override
diff --git a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoInfo.java b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoInfo.java
index 97a4f6b..fa96d04 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoInfo.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoInfo.java
@@ -25,7 +25,6 @@
 import com.google.devtools.build.lib.skylarkbuildapi.proto.ProtoBootstrap;
 import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.Location;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.util.Pair;
 import javax.annotation.Nullable;
 
@@ -147,7 +146,7 @@
    */
   @Override
   public Depset /*<String>*/ getTransitiveProtoSourceRootsForStarlark() {
-    return Depset.of(SkylarkType.STRING, transitiveProtoSourceRoots);
+    return Depset.of(Depset.ElementType.STRING, transitiveProtoSourceRoots);
   }
 
   public NestedSet<String> getTransitiveProtoSourceRoots() {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PyInfo.java b/src/main/java/com/google/devtools/build/lib/rules/python/PyInfo.java
index c283a8a..6044d2b 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/python/PyInfo.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/python/PyInfo.java
@@ -27,7 +27,6 @@
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.EvalUtils;
 import com.google.devtools.build.lib.syntax.Location;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.syntax.Starlark;
 import com.google.devtools.build.lib.syntax.StarlarkThread;
 import java.util.Objects;
@@ -45,9 +44,9 @@
    * order.
    */
   private static boolean depsetHasTypeAndCompatibleOrder(
-      Depset depset, SkylarkType type, Order order) {
+      Depset depset, Depset.ElementType type, Order order) {
     // Work around #7266 by special-casing the empty set in the type check.
-    boolean typeOk = depset.isEmpty() || depset.getContentType().equals(type);
+    boolean typeOk = depset.isEmpty() || depset.getElementType().equals(type);
     boolean orderOk = depset.getOrder().isCompatible(order);
     return typeOk && orderOk;
   }
@@ -88,7 +87,7 @@
     // that to NAIVE_LINK (preorder). In the meantime, order isn't an invariant of the provider
     // itself, so we use STABLE here to accept any order.
     Preconditions.checkArgument(
-        depsetHasTypeAndCompatibleOrder(imports, SkylarkType.STRING, Order.STABLE_ORDER));
+        depsetHasTypeAndCompatibleOrder(imports, Depset.ElementType.STRING, Order.STABLE_ORDER));
     this.location = location != null ? location : Location.BUILTIN;
     this.transitiveSources = transitiveSources;
     this.usesSharedLibraries = usesSharedLibraries;
@@ -143,7 +142,7 @@
       return transitiveSources.getSet(Artifact.class);
     } catch (TypeException e) {
       throw new IllegalStateException(
-          "'transitiveSources' depset was found to be invalid type " + imports.getContentType(), e);
+          "'transitiveSources' depset was found to be invalid type " + imports.getElementType(), e);
     }
   }
 
@@ -162,7 +161,7 @@
       return imports.getSet(String.class);
     } catch (TypeException e) {
       throw new IllegalStateException(
-          "'imports' depset was found to be invalid type " + imports.getContentType(), e);
+          "'imports' depset was found to be invalid type " + imports.getElementType(), e);
     }
   }
 
@@ -195,7 +194,7 @@
         throws EvalException {
       Depset imports =
           importsUncast.equals(Starlark.UNBOUND)
-              ? Depset.of(SkylarkType.STRING, NestedSetBuilder.emptySet(Order.COMPILE_ORDER))
+              ? Depset.of(Depset.ElementType.STRING, NestedSetBuilder.emptySet(Order.COMPILE_ORDER))
               : (Depset) importsUncast;
 
       if (!depsetHasTypeAndCompatibleOrder(transitiveSources, Artifact.TYPE, Order.COMPILE_ORDER)) {
@@ -204,7 +203,8 @@
                 + " '%s')",
             describeType(transitiveSources));
       }
-      if (!depsetHasTypeAndCompatibleOrder(imports, SkylarkType.STRING, Order.STABLE_ORDER)) {
+      if (!depsetHasTypeAndCompatibleOrder(
+          imports, Depset.ElementType.STRING, Order.STABLE_ORDER)) {
         throw Starlark.errorf(
             "'imports' field should be a depset of strings (got a '%s')", describeType(imports));
       }
@@ -274,7 +274,7 @@
           location,
           Depset.of(Artifact.TYPE, transitiveSources),
           usesSharedLibraries,
-          Depset.of(SkylarkType.STRING, imports),
+          Depset.of(Depset.ElementType.STRING, imports),
           hasPy2OnlySources,
           hasPy3OnlySources);
     }
diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PyStructUtils.java b/src/main/java/com/google/devtools/build/lib/rules/python/PyStructUtils.java
index 3d2c000..a6bd761 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/python/PyStructUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/python/PyStructUtils.java
@@ -24,7 +24,6 @@
 import com.google.devtools.build.lib.packages.StructProvider;
 import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.EvalException;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.syntax.Starlark;
 
 /** Static helper class for creating and accessing instances of the legacy "py" struct provider. */
@@ -76,7 +75,8 @@
     builder.put(USES_SHARED_LIBRARIES, false);
     builder.put(
         IMPORTS,
-        Depset.of(SkylarkType.STRING, NestedSetBuilder.<String>emptySet(Order.COMPILE_ORDER)));
+        Depset.of(
+            Depset.ElementType.STRING, NestedSetBuilder.<String>emptySet(Order.COMPILE_ORDER)));
     builder.put(HAS_PY2_ONLY_SOURCES, false);
     builder.put(HAS_PY3_ONLY_SOURCES, false);
     DEFAULTS = builder.build();
@@ -199,7 +199,7 @@
     }
 
     public Builder setImports(NestedSet<String> imports) {
-      this.imports = Depset.of(SkylarkType.STRING, imports);
+      this.imports = Depset.of(Depset.ElementType.STRING, imports);
       return this;
     }
 
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/DataBindingV2ProviderApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/DataBindingV2ProviderApi.java
index 5f7f072..a5bdaf7 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/DataBindingV2ProviderApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/DataBindingV2ProviderApi.java
@@ -24,7 +24,6 @@
 import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.Sequence;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.syntax.StarlarkValue;
 import javax.annotation.Nullable;
 
@@ -53,7 +52,7 @@
       documented = false)
   final class LabelJavaPackagePair implements StarlarkValue {
 
-    public static final SkylarkType TYPE = SkylarkType.of(LabelJavaPackagePair.class);
+    public static final Depset.ElementType TYPE = Depset.ElementType.of(LabelJavaPackagePair.class);
 
     private final String label;
     private final String javaPackage;
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/BUILD b/src/main/java/com/google/devtools/build/lib/syntax/BUILD
index 1bd3fac..2c73b24 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/syntax/BUILD
@@ -115,7 +115,6 @@
         "SkylarkClassObject.java",
         "SkylarkIndexable.java",
         "SkylarkQueryable.java",
-        "SkylarkType.java",
         "Starlark.java",
         "StarlarkCallable.java",
         "StarlarkFunction.java",
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Depset.java b/src/main/java/com/google/devtools/build/lib/syntax/Depset.java
index 2b98399..e799a2d 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Depset.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Depset.java
@@ -22,6 +22,7 @@
 import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
 import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
+import com.google.devtools.build.lib.skylarkinterface.SkylarkInterfaceUtils;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
 import java.util.List;
@@ -31,13 +32,13 @@
  * A Depset is a Starlark value that wraps a {@link NestedSet}.
  *
  * <p>A NestedSet has a type parameter that describes, at compile time, the elements of the set. By
- * contrast, a Depset has a value, {@link #getContentType}, that describes the elements during
+ * contrast, a Depset has a value, {@link #getElementType}, that describes the elements during
  * execution. This type symbol permits the element type of a Depset value to be queried, after the
  * type parameter has been erased, without visiting each element of the often-vast data structure.
  *
- * <p>The content type of a non-empty {@code Depset} is determined by its first element. All
- * elements must have the same type. An empty depset has type {@code SkylarkType.EMPTY}, and may be
- * combined with any other depset.
+ * <p>For depsets constructed by Starlark code, the element type of a non-empty {@code Depset} is
+ * determined by its first element. All elements must have the same type. An empty depset has type
+ * {@code ElementType.EMPTY}, and may be combined with any other depset.
  */
 // TODO(adonovan): move to lib.packages, as this is a Bazelism. Requires:
 // - moving the function to StarlarkLibrary.COMMON.
@@ -86,18 +87,18 @@
 @Immutable
 @AutoCodec
 public final class Depset implements StarlarkValue {
-  private final SkylarkType contentType;
+  private final ElementType elemType;
   private final NestedSet<?> set;
   @Nullable private final ImmutableList<Object> items; // TODO(laurentlb): Delete field.
   @Nullable private final ImmutableList<NestedSet<?>> transitiveItems;
 
   @AutoCodec.VisibleForSerialization
   Depset(
-      SkylarkType contentType,
+      ElementType elemType,
       NestedSet<?> set,
       ImmutableList<Object> items,
       ImmutableList<NestedSet<?>> transitiveItems) {
-    this.contentType = Preconditions.checkNotNull(contentType, "type cannot be null");
+    this.elemType = Preconditions.checkNotNull(elemType, "type cannot be null");
     this.set = set;
     this.items = items;
     this.transitiveItems = transitiveItems;
@@ -105,8 +106,7 @@
 
   // TODO(laurentlb): Remove the left argument once `unionOf` is deleted.
   private static Depset create(
-      Order order, SkylarkType contentType, Object item, @Nullable Depset left)
-      throws EvalException {
+      Order order, ElementType elemType, Object item, @Nullable Depset left) throws EvalException {
     ImmutableList.Builder<Object> itemsBuilder = ImmutableList.builder();
     ImmutableList.Builder<NestedSet<?>> transitiveItemsBuilder = ImmutableList.builder();
     if (left != null) {
@@ -121,14 +121,14 @@
     if (item instanceof Depset) {
       Depset nestedSet = (Depset) item;
       if (!nestedSet.isEmpty()) {
-        contentType = checkType(contentType, nestedSet.contentType);
+        elemType = checkType(elemType, nestedSet.elemType);
         transitiveItemsBuilder.add(nestedSet.set);
       }
     } else if (item instanceof Sequence) {
       for (Object x : (Sequence) item) {
         checkElement(x, /*strict=*/ true);
-        SkylarkType xt = SkylarkType.ofValue(x);
-        contentType = checkType(contentType, xt);
+        ElementType xt = ElementType.of(x.getClass());
+        elemType = checkType(elemType, xt);
         itemsBuilder.add(x);
       }
     } else {
@@ -148,7 +148,7 @@
       // Order mismatch between item and builder.
       throw Starlark.errorf("%s", e.getMessage());
     }
-    return new Depset(contentType, builder.build(), items, transitiveItems);
+    return new Depset(elemType, builder.build(), items, transitiveItems);
   }
 
   private static void checkElement(Object x, boolean strict) throws EvalException {
@@ -184,12 +184,12 @@
 
   // implementation of deprecated depset(x) constructor
   static Depset legacyOf(Order order, Object items) throws EvalException {
-    return create(order, SkylarkType.EMPTY, items, null);
+    return create(order, ElementType.EMPTY, items, null);
   }
 
   // TODO(laurentlb): Delete the method. It's used only in tests.
   static Depset unionOf(Depset left, Object right) throws EvalException {
-    return create(left.set.getOrder(), left.contentType, right, left);
+    return create(left.set.getOrder(), left.elemType, right, left);
   }
 
   /**
@@ -204,31 +204,35 @@
   // that would fail Starlark.valid; however remains the problem that
   // Object.class means "any Starlark value" but in fact allows any Java value.
   //
-  // TODO(adonovan): it is possible to create an empty depset with a contentType other than EMPTY.
-  // The union operation will fail if it's combined with another depset of incompatible contentType.
+  // TODO(adonovan): it is possible to create an empty depset with a elemType other than EMPTY.
+  // The union operation will fail if it's combined with another depset of incompatible elemType.
   // Options:
-  // - prohibit or ignore a non-EMPTY contentType when passed an empty NestedSet
-  // - continue to allow empty depsets to be distinguished by their nominal contentTypes for
+  // - prohibit or ignore a non-EMPTY elemType when passed an empty NestedSet
+  // - continue to allow empty depsets to be distinguished by their nominal elemTypes for
   //   union purposes, but allow casting them to NestedSet<T> for arbitrary T.
   // - distinguish them for both union and casting, i.e. replace set.isEmpty() with a check for the
   // empty type.
-  public static <T> Depset of(SkylarkType contentType, NestedSet<T> set) {
-    return new Depset(contentType, set, null, null);
+  //
+  // TODO(adonovan): if we replaced ElementType by Class, we could enforce consistency between the
+  // two arguments: of(Class<T> elemType, NestedSet<T> set). We could also avoid the allocations
+  // done by ElementType.of().
+  public static <T> Depset of(ElementType elemType, NestedSet<T> set) {
+    return new Depset(elemType, set, null, null);
   }
 
   /**
    * Checks that an item type is allowed in a given set type, and returns the type of a new depset
    * with that item inserted.
    */
-  private static SkylarkType checkType(SkylarkType depsetType, SkylarkType itemType)
+  private static ElementType checkType(ElementType existingElemType, ElementType newElemType)
       throws EvalException {
     // An initially empty depset takes its type from the first element added.
     // Otherwise, the types of the item and depset must match exactly.
-    if (depsetType.equals(SkylarkType.EMPTY) || depsetType.equals(itemType)) {
-      return itemType;
+    if (existingElemType.equals(ElementType.EMPTY) || existingElemType.equals(newElemType)) {
+      return newElemType;
     }
     throw Starlark.errorf(
-        "cannot add an item of type '%s' to a depset of '%s'", itemType, depsetType);
+        "cannot add an item of type '%s' to a depset of '%s'", newElemType, existingElemType);
   }
 
   /**
@@ -243,11 +247,11 @@
    * @throws TypeException if the type does not accurately describe all elements
    */
   public <T> NestedSet<T> getSet(Class<T> type) throws TypeException {
-    if (!set.isEmpty() && !contentType.canBeCastTo(type)) {
+    if (!set.isEmpty() && !elemType.canBeCastTo(type)) {
       throw new TypeException(
           String.format(
               "got a depset of '%s', expected a depset of '%s'",
-              contentType, EvalUtils.getDataTypeNameFromClass(type)));
+              elemType, EvalUtils.getDataTypeNameFromClass(type)));
     }
     @SuppressWarnings("unchecked")
     NestedSet<T> res = (NestedSet<T>) set;
@@ -325,8 +329,8 @@
     return !set.isEmpty();
   }
 
-  public SkylarkType getContentType() {
-    return contentType;
+  public ElementType getElementType() {
+    return elemType;
   }
 
   @Override
@@ -385,7 +389,7 @@
       Order order, List<Object> direct, List<Depset> transitive, boolean strict)
       throws EvalException {
     NestedSetBuilder<Object> builder = new NestedSetBuilder<>(order);
-    SkylarkType type = SkylarkType.EMPTY;
+    ElementType type = ElementType.EMPTY;
 
     // Check direct elements' type is equal to elements already added.
     for (Object x : direct) {
@@ -402,7 +406,7 @@
       // See b/144992997 or github.com/bazelbuild/bazel/issues/10289.
       checkElement(x, /*strict=*/ strict);
 
-      SkylarkType xt = SkylarkType.ofValue(x);
+      ElementType xt = ElementType.of(x.getClass());
       type = checkType(type, xt);
     }
     builder.addAll(direct);
@@ -410,7 +414,7 @@
     // Add transitive sets, checking that type is equal to elements already added.
     for (Depset x : transitive) {
       if (!x.isEmpty()) {
-        type = checkType(type, x.getContentType());
+        type = checkType(type, x.getElementType());
         if (!order.isCompatible(x.getOrder())) {
           throw Starlark.errorf(
               "Order '%s' is incompatible with order '%s'",
@@ -429,4 +433,106 @@
       super(message);
     }
   }
+
+  /**
+   * A ElementType represents the type of elements in a Depset.
+   *
+   * <p>Call {@link #of} to obtain the ElementType for a Java class. The class must be a legal
+   * Starlark value class, such as String, Integer, Boolean, or a subclass of StarlarkValue.
+   *
+   * <p>An element type represents only the top-most type identifier of an element value. That is,
+   * an element type may represent "list" but not "list of string".
+   */
+  // TODO(adonovan): consider deleting this class entirely and using Class directly.
+  // Depset.getElementType would need to document "null means empty",
+  // but almost every caller just wants to stringify it.
+  @Immutable
+  public static final class ElementType {
+
+    @Nullable private final Class<?> cls; // null => empty depset
+
+    private ElementType(@Nullable Class<?> cls) {
+      this.cls = cls;
+    }
+
+    /** The element type of the empty depset. */
+    public static final ElementType EMPTY = new ElementType(null);
+
+    /** The element type of a depset of strings. */
+    public static final ElementType STRING = of(String.class);
+
+    @Override
+    public String toString() {
+      return cls == null ? "empty" : EvalUtils.getDataTypeNameFromClass(cls);
+    }
+
+    /**
+     * Returns the type symbol for a depset whose elements are instances of {@code cls}.
+     *
+     * @throws IllegalArgumentException if {@code cls} is not a legal Starlark value class.
+     */
+    public static ElementType of(Class<?> cls) {
+      return new ElementType(getTypeClass(cls));
+    }
+
+    // Returns the Java class representing the Starlark type of an instance of cls,
+    // which must be one of String, Integer, or Boolean (in which case the result is cls),
+    // or a SkylarkModule-annotated Starlark value class or one of its subclasses,
+    // in which case the result is the annotated class.
+    //
+    // TODO(adonovan): consider publishing something like this as Starlark.typeClass
+    // when we clean up the various EvalUtils.getDataType operators.
+    private static Class<?> getTypeClass(Class<?> cls) {
+      if (cls == String.class || cls == Integer.class || cls == Boolean.class) {
+        return cls; // fast path for common case
+      }
+      Class<?> superclass = SkylarkInterfaceUtils.getParentWithSkylarkModule(cls);
+      if (superclass != null) {
+        return superclass;
+      }
+      if (!StarlarkValue.class.isAssignableFrom(cls)) {
+        throw new IllegalArgumentException(
+            "invalid Depset element type: "
+                + cls.getName()
+                + " is not a subclass of StarlarkValue");
+      }
+      return cls;
+    }
+
+    // Called by precondition check of Depset.getSet conversion.
+    //
+    // Fails if cls is neither Object.class nor a valid Starlark value class.
+    // One might expect that if a ElementType canBeCastTo Integer, then it can
+    // also be cast to Number, but this is not the case: getTypeClass fails if
+    // passed a supertype of a Starlark class that is not itself a valid Starlark
+    // value class. As a special case, Object.class is permitted,
+    // and represents "any value".
+    //
+    // This leads one to wonder why canBeCastTo calls getTypeClass at all.
+    // The answer is that it is yet another hack to support skylarkbuildapi.
+    // For example, (FileApi).canBeCastTo(Artifact.class) reports true,
+    // because a Depset whose elements are nominally of type FileApi is assumed
+    // to actually contain only elements of class Artifact. If there were
+    // a second implementation of FileAPI, the operation would be unsafe.
+    //
+    // TODO(adonovan): once skylarkbuildapi has been deleted, eliminate the
+    // getTypeClass calls here and in ElementType.of, and remove the special
+    // case for Object.class since isAssignableFrom will allow any supertype
+    // of the element type, whether or not it is a Starlark value class.
+    private boolean canBeCastTo(Class<?> cls) {
+      return this.cls == null
+          || cls == Object.class // historical exception
+          || getTypeClass(cls).isAssignableFrom(this.cls);
+    }
+
+    @Override
+    public int hashCode() {
+      return cls == null ? 0 : cls.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      return that instanceof ElementType && this.cls == ((ElementType) that).cls;
+    }
+  }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java b/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java
index 298ebf6..466f6c6 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java
@@ -177,7 +177,7 @@
     if (fullDetails) {
       if (object instanceof Depset) {
         Depset set = (Depset) object;
-        return "depset of " + set.getContentType() + "s";
+        return "depset of " + set.getElementType() + "s";
       }
     }
     return getDataTypeNameFromClass(object.getClass());
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Parameter.java b/src/main/java/com/google/devtools/build/lib/syntax/Parameter.java
index 5c92f0c..7a5f804 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Parameter.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Parameter.java
@@ -23,9 +23,6 @@
  *
  * <p>See FunctionSignature for how a valid list of Parameters is organized as a signature, e.g. def
  * foo(mandatory, optional = e1, *args, mandatorynamedonly, optionalnamedonly = e2, **kw): ...
- *
- * <p>V is the class of a defaultValue (Expression at compile-time, Object at runtime), T is the
- * class of a type (Expression at compile-time, SkylarkType at runtime).
  */
 public abstract class Parameter extends Node {
 
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkType.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkType.java
deleted file mode 100644
index 57fe9f0..0000000
--- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkType.java
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2014 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.syntax;
-
-import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
-import com.google.devtools.build.lib.skylarkinterface.SkylarkInterfaceUtils;
-import javax.annotation.Nullable;
-
-/** A SkylarkType represents the top-level class of the elements of a Depset. */
-// TODO(adonovan): move to Depset.ElementType.
-// TODO(adonovan): consider deleting this class entirely and using Class directly
-// within Depset. Depset.getContentType would need to document "null means empty",
-// but almost every caller just wants to stringify it.
-@Immutable
-public final class SkylarkType {
-
-  @Nullable private final Class<?> cls; // null => empty depset
-
-  private SkylarkType(@Nullable Class<?> cls) {
-    this.cls = cls;
-  }
-
-  /** The element type of the empty depset. */
-  public static final SkylarkType EMPTY = new SkylarkType(null);
-
-  /** The element type of a depset of strings. */
-  public static final SkylarkType STRING = of(String.class);
-
-  @Override
-  public String toString() {
-    return cls == null ? "empty" : EvalUtils.getDataTypeNameFromClass(cls);
-  }
-
-  /** Returns the symbol representing the element type of a depset. */
-  public static SkylarkType of(Class<?> cls) {
-    return new SkylarkType(getTypeClass(cls));
-  }
-
-  // Returns the Java class representing the Starlark type of an instance of cls, which must be one
-  // of String, Integer, or Boolean (in which case the result is cls), or a SkylarkModule-annotated
-  // Starlark value class or one of its subclasses, in which case the result is the annotated class.
-  //
-  // TODO(adonovan): consider publishing something like this as Starlark.typeClass when we clean up
-  // the various EvalUtils.getDataType operators.
-  private static Class<?> getTypeClass(Class<?> cls) {
-    if (cls == String.class || cls == Integer.class || cls == Boolean.class) {
-      return cls; // fast path for common case
-    }
-    Class<?> superclass = SkylarkInterfaceUtils.getParentWithSkylarkModule(cls);
-    if (superclass != null) {
-      return superclass;
-    }
-    if (!StarlarkValue.class.isAssignableFrom(cls)) {
-      throw new IllegalArgumentException(
-          "invalid Depset element type: " + cls.getName() + " is not a subclass of StarlarkValue");
-    }
-    return cls;
-  }
-
-  /** Returns the symbol representing elements of the same class as x. */
-  // Called by Depset element insertion.
-  static SkylarkType ofValue(Object x) {
-    return of(x.getClass());
-  }
-
-  // Called by precondition check of Depset.getSet conversion.
-  //
-  // Fails if cls is neither Object.class nor a valid Starlark value class. One might expect that if
-  // a SkylarkType canBeCastTo Integer, then it can also be cast to Number, but this is not the
-  // case: getTypeClass fails if passed a supertype of a Starlark class that is not itself a valid
-  // Starlark value class. As a special case, Object.class is permitted, and represents "any value".
-  //
-  // This leads one to wonder why canBeCastTo calls getTypeClass at all. The answer is that it is
-  // yet another hack to support skylarkbuildapi. For example, (FileApi).canBeCastTo(Artifact.class)
-  // reports true, because a Depset whose elements are nominally of type FileApi is assumed to
-  // actually contain only elements of class Artifact. If there were a second implementation of
-  // FileAPI, the operation would be unsafe.
-  //
-  // TODO(adonovan): once skylarkbuildapi has been deleted, eliminate the getTypeClass calls here
-  // and in SkylarkType.of, and remove the special case for Object.class since isAssignableFrom will
-  // allow any supertype of the element type, whether or not it is a Starlark value class.
-  boolean canBeCastTo(Class<?> cls) {
-    return this.cls == null
-        || cls == Object.class // historical exception
-        || getTypeClass(cls).isAssignableFrom(this.cls);
-  }
-
-  @Override
-  public int hashCode() {
-    return cls == null ? 0 : cls.hashCode();
-  }
-
-  @Override
-  public boolean equals(Object that) {
-    return that instanceof SkylarkType && this.cls == ((SkylarkType) that).cls;
-  }
-}
diff --git a/src/test/java/com/google/devtools/build/lib/packages/TypeTest.java b/src/test/java/com/google/devtools/build/lib/packages/TypeTest.java
index 53680b7..78772cd 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/TypeTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/TypeTest.java
@@ -24,7 +24,6 @@
 import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
 import com.google.devtools.build.lib.collect.nestedset.Order;
 import com.google.devtools.build.lib.syntax.Depset;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.syntax.StarlarkList;
 import com.google.devtools.build.lib.syntax.Tuple;
 import com.google.devtools.build.lib.testutil.MoreAsserts;
@@ -279,7 +278,8 @@
   @Test
   public void testListDepsetConversion() throws Exception {
     Object input =
-        Depset.of(SkylarkType.STRING, NestedSetBuilder.create(Order.STABLE_ORDER, "a", "b", "c"));
+        Depset.of(
+            Depset.ElementType.STRING, NestedSetBuilder.create(Order.STABLE_ORDER, "a", "b", "c"));
     Type.STRING_LIST.convert(input, null);
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/rules/python/PyStructUtilsTest.java b/src/test/java/com/google/devtools/build/lib/rules/python/PyStructUtilsTest.java
index 0e268f0..1c8cdcc 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/python/PyStructUtilsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/python/PyStructUtilsTest.java
@@ -29,7 +29,6 @@
 import com.google.devtools.build.lib.packages.StructProvider;
 import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.EvalException;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.testutil.FoundationTestCase;
 import com.google.devtools.build.lib.vfs.Root;
 import java.util.LinkedHashMap;
@@ -70,7 +69,7 @@
     fields.put(PyStructUtils.USES_SHARED_LIBRARIES, false);
     fields.put(
         PyStructUtils.IMPORTS,
-        Depset.of(SkylarkType.STRING, NestedSetBuilder.emptySet(Order.COMPILE_ORDER)));
+        Depset.of(Depset.ElementType.STRING, NestedSetBuilder.emptySet(Order.COMPILE_ORDER)));
     fields.put(PyStructUtils.HAS_PY2_ONLY_SOURCES, false);
     fields.put(PyStructUtils.HAS_PY3_ONLY_SOURCES, false);
     fields.putAll(overrides);
@@ -161,7 +160,8 @@
   public void getImports_Good() throws Exception {
     NestedSet<String> imports = NestedSetBuilder.create(Order.COMPILE_ORDER, "abc");
     StructImpl info =
-        makeStruct(ImmutableMap.of(PyStructUtils.IMPORTS, Depset.of(SkylarkType.STRING, imports)));
+        makeStruct(
+            ImmutableMap.of(PyStructUtils.IMPORTS, Depset.of(Depset.ElementType.STRING, imports)));
     assertThat(PyStructUtils.getImports(info)).isSameInstanceAs(imports);
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/skylarkdebug/server/DebuggerSerializationTest.java b/src/test/java/com/google/devtools/build/lib/skylarkdebug/server/DebuggerSerializationTest.java
index 8bbe3ad..a7c24f5 100644
--- a/src/test/java/com/google/devtools/build/lib/skylarkdebug/server/DebuggerSerializationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylarkdebug/server/DebuggerSerializationTest.java
@@ -27,7 +27,6 @@
 import com.google.devtools.build.lib.syntax.Depset;
 import com.google.devtools.build.lib.syntax.EvalUtils;
 import com.google.devtools.build.lib.syntax.Printer;
-import com.google.devtools.build.lib.syntax.SkylarkType;
 import com.google.devtools.build.lib.syntax.Starlark;
 import com.google.devtools.build.lib.syntax.StarlarkValue;
 import java.util.List;
@@ -63,7 +62,8 @@
   public void testSimpleNestedSet() {
     Set<String> children = ImmutableSet.of("a", "b");
     Depset set =
-        Depset.of(SkylarkType.STRING, NestedSetBuilder.stableOrder().addAll(children).build());
+        Depset.of(
+            Depset.ElementType.STRING, NestedSetBuilder.stableOrder().addAll(children).build());
 
     Value value = getValueProto("name", set);
 
@@ -92,7 +92,7 @@
     ImmutableSet<String> directChildren = ImmutableSet.of("a", "b");
     Depset outerSet =
         Depset.of(
-            SkylarkType.STRING,
+            Depset.ElementType.STRING,
             NestedSetBuilder.<String>linkOrder()
                 .addAll(directChildren)
                 .addTransitive(innerNestedSet)
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/DepsetTest.java b/src/test/java/com/google/devtools/build/lib/syntax/DepsetTest.java
index 3c55191..311f45d 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/DepsetTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/DepsetTest.java
@@ -18,6 +18,7 @@
 
 import com.google.devtools.build.lib.collect.nestedset.NestedSet;
 import com.google.devtools.build.lib.collect.nestedset.Order;
+import com.google.devtools.build.lib.syntax.Depset.ElementType;
 import com.google.devtools.build.lib.syntax.util.EvaluationTestCase;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -37,7 +38,7 @@
     assertThat(lookup("s")).isInstanceOf(Depset.class);
   }
 
-  private static final SkylarkType TUPLE = SkylarkType.of(Tuple.class);
+  private static final ElementType TUPLE = ElementType.of(Tuple.class);
 
   @Test
   public void testTuples() throws Exception {
@@ -50,10 +51,10 @@
         "s_six = depset(transitive = [s_one, s_five])",
         "s_seven = depset(direct = [('1', '3')], transitive = [s_one, s_five])",
         "s_eight = depset(direct = [(1, 3)], transitive = [s_one, s_two])"); // note, tuple of int
-    assertThat(get("s_one").getContentType()).isEqualTo(TUPLE);
-    assertThat(get("s_two").getContentType()).isEqualTo(TUPLE);
-    assertThat(get("s_three").getContentType()).isEqualTo(TUPLE);
-    assertThat(get("s_eight").getContentType()).isEqualTo(TUPLE);
+    assertThat(get("s_one").getElementType()).isEqualTo(TUPLE);
+    assertThat(get("s_two").getElementType()).isEqualTo(TUPLE);
+    assertThat(get("s_three").getElementType()).isEqualTo(TUPLE);
+    assertThat(get("s_eight").getElementType()).isEqualTo(TUPLE);
 
     assertThat(get("s_four").getSet(Tuple.class).toList())
         .containsExactly(
@@ -167,31 +168,31 @@
   @Test
   public void testEmptyGenericType() throws Exception {
     exec("s = depset()");
-    assertThat(get("s").getContentType()).isEqualTo(SkylarkType.EMPTY);
+    assertThat(get("s").getElementType()).isEqualTo(ElementType.EMPTY);
   }
 
   @Test
   public void testHomogeneousGenericType() throws Exception {
     exec("s = depset(['a', 'b', 'c'])");
-    assertThat(get("s").getContentType()).isEqualTo(SkylarkType.STRING);
+    assertThat(get("s").getElementType()).isEqualTo(ElementType.STRING);
   }
 
   @Test
   public void testHomogeneousGenericTypeDirect() throws Exception {
     exec("s = depset(['a', 'b', 'c'], transitive = [])");
-    assertThat(get("s").getContentType()).isEqualTo(SkylarkType.STRING);
+    assertThat(get("s").getElementType()).isEqualTo(ElementType.STRING);
   }
 
   @Test
   public void testHomogeneousGenericTypeItems() throws Exception {
     exec("s = depset(items = ['a', 'b', 'c'], transitive = [])");
-    assertThat(get("s").getContentType()).isEqualTo(SkylarkType.STRING);
+    assertThat(get("s").getElementType()).isEqualTo(ElementType.STRING);
   }
 
   @Test
   public void testHomogeneousGenericTypeTransitive() throws Exception {
     exec("s = depset(['a', 'b', 'c'], transitive = [depset(['x'])])");
-    assertThat(get("s").getContentType()).isEqualTo(SkylarkType.STRING);
+    assertThat(get("s").getElementType()).isEqualTo(ElementType.STRING);
   }
 
   @Test
@@ -539,30 +540,30 @@
   }
 
   @Test
-  public void testSkylarkTypeOf() {
+  public void testElementTypeOf() {
     // legal values
-    assertThat(SkylarkType.of(String.class).toString()).isEqualTo("string");
-    assertThat(SkylarkType.of(Integer.class).toString()).isEqualTo("int");
-    assertThat(SkylarkType.of(Boolean.class).toString()).isEqualTo("bool");
+    assertThat(ElementType.of(String.class).toString()).isEqualTo("string");
+    assertThat(ElementType.of(Integer.class).toString()).isEqualTo("int");
+    assertThat(ElementType.of(Boolean.class).toString()).isEqualTo("bool");
 
     // concrete non-values
-    assertThrows(IllegalArgumentException.class, () -> SkylarkType.of(Float.class));
+    assertThrows(IllegalArgumentException.class, () -> ElementType.of(Float.class));
 
     // concrete classes that implement StarlarkValue
-    assertThat(SkylarkType.of(StarlarkList.class).toString()).isEqualTo("list");
-    assertThat(SkylarkType.of(Tuple.class).toString()).isEqualTo("tuple");
-    assertThat(SkylarkType.of(Dict.class).toString()).isEqualTo("dict");
+    assertThat(ElementType.of(StarlarkList.class).toString()).isEqualTo("list");
+    assertThat(ElementType.of(Tuple.class).toString()).isEqualTo("tuple");
+    assertThat(ElementType.of(Dict.class).toString()).isEqualTo("dict");
     class V implements StarlarkValue {} // no SkylarkModule annotation
-    assertThat(SkylarkType.of(V.class).toString()).isEqualTo("V");
+    assertThat(ElementType.of(V.class).toString()).isEqualTo("V");
 
     // abstract classes that implement StarlarkValue
-    assertThat(SkylarkType.of(Sequence.class).toString()).isEqualTo("sequence");
-    assertThat(SkylarkType.of(StarlarkCallable.class).toString()).isEqualTo("function");
-    assertThat(SkylarkType.of(StarlarkIterable.class).toString()).isEqualTo("StarlarkIterable");
+    assertThat(ElementType.of(Sequence.class).toString()).isEqualTo("sequence");
+    assertThat(ElementType.of(StarlarkCallable.class).toString()).isEqualTo("function");
+    assertThat(ElementType.of(StarlarkIterable.class).toString()).isEqualTo("StarlarkIterable");
 
     // superclasses of legal values that aren't values themselves
-    assertThrows(IllegalArgumentException.class, () -> SkylarkType.of(Number.class));
-    assertThrows(IllegalArgumentException.class, () -> SkylarkType.of(CharSequence.class));
-    assertThrows(IllegalArgumentException.class, () -> SkylarkType.of(Object.class));
+    assertThrows(IllegalArgumentException.class, () -> ElementType.of(Number.class));
+    assertThrows(IllegalArgumentException.class, () -> ElementType.of(CharSequence.class));
+    assertThrows(IllegalArgumentException.class, () -> ElementType.of(Object.class));
   }
 }