diff options
4 files changed, 55 insertions, 10 deletions
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 9fda709fa1..814d199000 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 @@ package com.google.devtools.build.lib.analysis.skylark; 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 @@ import java.util.List; "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 class SkylarkFileType { 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 76b4f8b4f5..697c317825 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 @@ public final class Environment implements Freezable { } 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 244d203c8f..f70a49884f 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.base.Preconditions; 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 @@ import java.util.List; * ) * </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 @@ public final class SelectorList implements SkylarkValue { 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 final class SelectorList implements SkylarkValue { 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); + } } diff --git a/src/test/java/com/google/devtools/build/lib/syntax/EnvironmentTest.java b/src/test/java/com/google/devtools/build/lib/syntax/EnvironmentTest.java index 44d8c1c6ab..f1339bd4ce 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/EnvironmentTest.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/EnvironmentTest.java @@ -348,9 +348,9 @@ public class EnvironmentTest extends EvaluationTestCase { assertCheckStateFailsWithMessage( new Extension(ImmutableMap.of("x", 1, "y", "foo", "z", true), "abc"), new Extension(ImmutableMap.of("x", 2.0, "y", "foo", "z", false), "abc"), - "bindings are unequal: x: this one has 1 (class java.lang.Integer), but given one has 2.0 " - + "(class java.lang.Double); z: this one has True (class java.lang.Boolean), but given " - + "one has False (class java.lang.Boolean)"); + "bindings are unequal: x: this one has 1 (class java.lang.Integer, 1), but given one has " + + "2.0 (class java.lang.Double, 2.0); z: this one has True (class java.lang.Boolean, " + + "true), but given one has False (class java.lang.Boolean, false)"); } @Test |