Automated rollback of commit 316cd7da6f6b003b853ccf7d144f395a9a557400.

*** Reason for rollback ***

Roll-forward with fix (equality and hashcode for relevant classes). Also add a bit more debugging info in case of failure.

PiperOrigin-RevId: 190492934
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkFileType.java b/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkFileType.java
index 9fda709..814d199 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkFileType.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkFileType.java
@@ -16,6 +16,7 @@
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableList;
 import com.google.devtools.build.lib.actions.Artifact;
+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.SkylarkModule;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
@@ -33,11 +34,13 @@
       "Deprecated. File type for file filtering. Can be used to filter collections of labels "
           + "for certain file types."
 )
+@AutoCodec
 public class SkylarkFileType {
 
   private final FileType fileType;
 
-  private SkylarkFileType(FileType fileType) {
+  @AutoCodec.VisibleForSerialization
+  SkylarkFileType(FileType fileType) {
     this.fileType = fileType;
   }
 
@@ -69,4 +72,21 @@
   public Object getExtensions() {
     return fileType.getExtensions();
   }
+
+  @Override
+  public int hashCode() {
+    return fileType.hashCode();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    return other == this
+        || (other instanceof SkylarkFileType
+            && this.fileType.equals(((SkylarkFileType) other).fileType));
+  }
+
+  @Override
+  public String toString() {
+    return fileType.toString();
+  }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Environment.java b/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
index 76b4f8b..697c317 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
@@ -602,12 +602,14 @@
         }
         badEntries.add(
             String.format(
-                "%s: this one has %s (class %s), but given one has %s (class %s)",
+                "%s: this one has %s (class %s, %s), but given one has %s (class %s, %s)",
                 name,
                 Printer.repr(value),
                 value.getClass().getName(),
+                value,
                 Printer.repr(otherValue),
-                otherValue.getClass().getName()));
+                otherValue.getClass().getName(),
+                otherValue));
       }
       if (!badEntries.isEmpty()) {
         throw new IllegalStateException(
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SelectorList.java b/src/main/java/com/google/devtools/build/lib/syntax/SelectorList.java
index 244d203..f70a498 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/SelectorList.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/SelectorList.java
@@ -17,10 +17,12 @@
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.devtools.build.lib.events.Location;
+import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkPrinter;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkValue;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * An attribute value consisting of a concatenation of native types and selects, e.g:
@@ -39,9 +41,12 @@
  *   )
  * </pre>
  */
-@SkylarkModule(name = "select",
-    doc = "A selector between configuration-dependent entities.",
-    documented = false)
+@SkylarkModule(
+  name = "select",
+  doc = "A selector between configuration-dependent entities.",
+  documented = false
+)
+@AutoCodec
 public final class SelectorList implements SkylarkValue {
   // TODO(build-team): Selectors are currently split between .packages and .syntax . They should
   // really all be in .packages, but then we'd need to figure out a way how to extend binary
@@ -49,7 +54,8 @@
   private final Class<?> type;
   private final List<Object> elements;
 
-  private SelectorList(Class<?> type, List<Object> elements) {
+  @AutoCodec.VisibleForSerialization
+  SelectorList(Class<?> type, List<Object> elements) {
     this.type = type;
     this.elements = elements;
   }
@@ -167,4 +173,21 @@
   public void repr(SkylarkPrinter printer) {
     printer.printList(elements, "", " + ", "", null);
   }
+
+  @Override
+  public int hashCode() {
+    return Objects.hash(type, elements);
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (this == other) {
+      return true;
+    }
+    if (!(other instanceof SelectorList)) {
+      return false;
+    }
+    SelectorList that = (SelectorList) other;
+    return Objects.equals(this.type, that.type) && Objects.equals(this.elements, that.elements);
+  }
 }