Skip to content

Commit

Permalink
Hash[Map[K, V]] has unnecessary constraint #3039
Browse files Browse the repository at this point in the history
  • Loading branch information
vasiliybondarenko committed Sep 13, 2019
1 parent 5f8b2f4 commit 15f0429
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions core/src/main/scala/cats/instances/sortedSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ trait SortedSetInstances extends SortedSetInstances1 {
private[instances] trait SortedSetInstances1 {
@deprecated("2.0.0-RC2", "Use cats.kernel.instances.sortedSet.catsKernelStdHashForSortedSet")
private[instances] def catsKernelStdHashForSortedSet[A: Order: Hash]: Hash[SortedSet[A]] =
cats.kernel.instances.sortedSet.catsKernelStdHashForSortedSet[A]
cats.kernel.instances.sortedSet.catsKernelStdHashForSortedSet1[A]

@deprecated("2.0.0-RC2", "Use cats.kernel.instances.sortedSet.catsKernelStdSemilatticeForSortedSet")
private[instances] def catsKernelStdSemilatticeForSortedSet[A: Order]: BoundedSemilattice[SortedSet[A]] =
Expand All @@ -94,7 +94,7 @@ private[instances] trait SortedSetInstancesBinCompat0 {
private[instances] trait SortedSetInstancesBinCompat1 extends LowPrioritySortedSetInstancesBinCompat1 {
// TODO: Remove when this is no longer necessary for binary compatibility.
implicit override def catsKernelStdHashForSortedSet[A: Order: Hash]: Hash[SortedSet[A]] =
cats.kernel.instances.sortedSet.catsKernelStdHashForSortedSet[A]
cats.kernel.instances.sortedSet.catsKernelStdHashForSortedSet1[A]
}

private[instances] trait LowPrioritySortedSetInstancesBinCompat1
Expand All @@ -104,7 +104,7 @@ private[instances] trait LowPrioritySortedSetInstancesBinCompat1
cats.kernel.instances.sortedSet.catsKernelStdOrderForSortedSet[A]

override def catsKernelStdHashForSortedSet[A: Order: Hash]: Hash[SortedSet[A]] =
cats.kernel.instances.sortedSet.catsKernelStdHashForSortedSet[A]
cats.kernel.instances.sortedSet.catsKernelStdHashForSortedSet1[A]
}

@deprecated("2.0.0-RC2", "Use cats.kernel.instances.SortedSetHash")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package cats.kernel
package instances

import cats.kernel.{BoundedSemilattice, Hash, Order}
import scala.collection.immutable.SortedSet

trait SortedSetInstances extends SortedSetInstances1 {
implicit def catsKernelStdHashForSortedSet[A: Order: Hash]: Hash[SortedSet[A]] =
@deprecated("Will be removed after dropping Scala 2.11 support", "")
def catsKernelStdHashForSortedSet[A: Order: Hash]: Hash[SortedSet[A]] =
new SortedSetHash[A]

implicit def catsKernelStdHashForSortedSet1[A: Hash]: Hash[SortedSet[A]] =
new SortedSetHash[A]
}

Expand All @@ -28,7 +31,7 @@ class SortedSetOrder[A: Order] extends Order[SortedSet[A]] {
StaticMethods.iteratorEq(s1.iterator, s2.iterator)
}

class SortedSetHash[A: Order: Hash] extends Hash[SortedSet[A]] {
class SortedSetHash[A: Hash] extends Hash[SortedSet[A]] {
import scala.util.hashing.MurmurHash3._

// adapted from [[scala.util.hashing.MurmurHash3]],
Expand All @@ -50,7 +53,7 @@ class SortedSetHash[A: Order: Hash] extends Hash[SortedSet[A]] {
finalizeHash(h, n)
}
override def eqv(s1: SortedSet[A], s2: SortedSet[A]): Boolean =
StaticMethods.iteratorEq(s1.iterator, s2.iterator)(Order[A])
StaticMethods.iteratorEq(s1.iterator, s2.iterator)(Eq[A])
}

class SortedSetSemilattice[A: Order] extends BoundedSemilattice[SortedSet[A]] {
Expand Down

0 comments on commit 15f0429

Please sign in to comment.