Skip to content

Commit 672f58c

Browse files
Googlercopybara-github
Googler
authored andcommitted
Delegate Depset's equals/hashCode to the underlying NestedSet.
This ensures that two Depsets with the same underlying NestedSet have the same hash. PiperOrigin-RevId: 324302869
1 parent f7c0557 commit 672f58c

File tree

1 file changed

+13
-0
lines changed
  • src/main/java/com/google/devtools/build/lib/collect/nestedset

1 file changed

+13
-0
lines changed

src/main/java/com/google/devtools/build/lib/collect/nestedset/Depset.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,4 +611,17 @@ public static boolean setDepthLimit(int newLimit) {
611611
// The effective default value comes from the --nested_set_depth_limit
612612
// flag in NestedSetOptionsModule, which overrides this.
613613
private static final AtomicInteger depthLimit = new AtomicInteger(3500);
614+
615+
// Delegate equality to the underlying NestedSet. Otherwise, it's possible to create multiple
616+
// Depset instances wrapping the same NestedSet that aren't equal to each other.
617+
618+
@Override
619+
public int hashCode() {
620+
return set.hashCode();
621+
}
622+
623+
@Override
624+
public boolean equals(Object other) {
625+
return other instanceof Depset && set.equals(((Depset) other).set);
626+
}
614627
}

0 commit comments

Comments
 (0)