diff --git a/src/main/java/io/vavr/collection/LinkedHashMap.java b/src/main/java/io/vavr/collection/LinkedHashMap.java index 28f255cb5..867113ea7 100644 --- a/src/main/java/io/vavr/collection/LinkedHashMap.java +++ b/src/main/java/io/vavr/collection/LinkedHashMap.java @@ -971,7 +971,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Collections.hashUnordered(this); + return Collections.hashOrdered(this); } private Object readResolve() { diff --git a/src/test/java/io/vavr/collection/CollectionsTest.java b/src/test/java/io/vavr/collection/CollectionsTest.java index b18bd3e77..b68e450b0 100644 --- a/src/test/java/io/vavr/collection/CollectionsTest.java +++ b/src/test/java/io/vavr/collection/CollectionsTest.java @@ -233,7 +233,7 @@ private void forAll(List> traversables, boolean value) { for (Traversable traversable2 : traversables) { if (traversable1 != traversable2) { assertThat(traversable1.equals(traversable2)).isEqualTo(value); - if (value) { + if (value && traversable1.getClass().equals(traversable2.getClass())) { assertThat(traversable1.hashCode() == traversable2.hashCode()).isTrue(); } }