Skip to content

Commit

Permalink
remove scala collection compat
Browse files Browse the repository at this point in the history
  • Loading branch information
massimosiani committed Feb 23, 2024
1 parent 84b30e9 commit efe55f8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ lazy val kernelLaws = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.settings(testingDependencies)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
.jvmSettings(libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "2.11.0" % Test)
.nativeSettings(commonNativeSettings)

lazy val algebraSettings = Seq[Setting[?]](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
package cats.kernel
package laws

import cats.kernel.compat.scalaVersionSpecific.*
import cats.kernel.instances.currency.*
import cats.kernel.laws.discipline.*
import munit.DisciplineSuite
import java.util.Currency
import org.scalacheck.{Arbitrary, Cogen, Gen}
import scala.jdk.CollectionConverters.*

class JvmLawTests extends TestsConfig with DisciplineSuite {
implicit private val arbitraryCurrency: Arbitrary[Currency] = Arbitrary(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

package cats.kernel.compat
import scala.annotation.{Annotation, StaticAnnotation}
import scala.collection.{IterableLike, TraversableLike}
import scala.collection.{mutable, IterableLike, TraversableLike}
import scala.collection.convert.ImplicitConversionsToScala.*

private[cats] object scalaVersionSpecific {

Expand All @@ -48,4 +49,8 @@ private[cats] object scalaVersionSpecific {
that: T
)(implicit w1: A => TraversableLike[El1, Repr1], w2: T => IterableLike[El2, Repr2]) = (a, that).zipped
}

implicit class setExtension[A](private val a: A) extends AnyVal {
def asScala(s: java.util.Set[A]): mutable.Set[A] = `set asScala`(s)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ package kernel

package compat
import scala.annotation.{Annotation, StaticAnnotation}
import scala.collection.mutable
import scala.jdk.CollectionConverters.*

private[cats] object scalaVersionSpecific {

Expand All @@ -35,4 +37,8 @@ private[cats] object scalaVersionSpecific {
implicit class iterableOnceExtension[A](private val io: IterableOnce[A]) extends AnyVal {
def reduceOption(f: (A, A) => A): Option[A] = io.iterator.reduceOption(f)
}

implicit class setExtension[A](private val s: java.util.Set[A]) extends AnyVal {
def asScala: mutable.Set[A] = SetHasAsScala(s).asScala
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,5 @@ package instances
import java.util.Currency

trait CurrencyInstances {
implicit def catsKernelStdHashForCurrency: Hash[Currency] = new CurrencyHash
}

class CurrencyHash extends Hash[Currency] {
override def eqv(x: Currency, y: Currency): Boolean = x.getCurrencyCode().equals(y.getCurrencyCode())
override def hash(x: Currency): Int = x.getCurrencyCode().hashCode()
implicit val catsKernelStdHashForCurrency: Hash[Currency] = Hash.fromUniversalHashCode[Currency]
}

0 comments on commit efe55f8

Please sign in to comment.