Skip to content

Commit

Permalink
Merge pull request #4219 from satorg/expose-newtype-objects-to-mima
Browse files Browse the repository at this point in the history
Expose newtype objects to Mima
  • Loading branch information
satorg authored Jun 11, 2022
2 parents e070e7e + d6fb9df commit 113da92
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
15 changes: 11 additions & 4 deletions core/src/main/scala/cats/data/NonEmptyChain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@
package cats
package data

import NonEmptyChainImpl.create

import cats.instances.StaticMethods
import cats.kernel._

import scala.collection.immutable.SortedMap

private[data] object NonEmptyChainImpl extends NonEmptyChainInstances with ScalaVersionSpecificNonEmptyChainImpl {
/**
* Actual implementation for [[cats.data.NonEmptyChain]]
*
* @note This object is kept public for the sake of binary compatibility only
* and therefore is subject to changes in future versions of Cats.
* Do not use directly - use [[cats.data.NonEmptyChain]] instead.
*/
object NonEmptyChainImpl extends NonEmptyChainInstances with ScalaVersionSpecificNonEmptyChainImpl {
// The following 3 types are components of a technique to
// create a no-boxing newtype. It's copied from the
// newtypes lib by @alexknvl
Expand Down Expand Up @@ -83,10 +88,12 @@ class NonEmptyChainOps[A](private val value: NonEmptyChain[A])
extends AnyVal
with NonEmptyCollection[A, Chain, NonEmptyChain] {

import NonEmptyChainImpl.{create, unwrap}

/**
* Converts this chain to a `Chain`
*/
final def toChain: Chain[A] = NonEmptyChainImpl.unwrap(value)
final def toChain: Chain[A] = unwrap(value)

/**
* Returns a new NonEmptyChain consisting of `a` followed by this. O(1) runtime.
Expand Down
9 changes: 8 additions & 1 deletion core/src/main/scala/cats/data/NonEmptyMapImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ import cats.kernel._

import scala.collection.immutable._

private[data] object NonEmptyMapImpl extends NonEmptyMapInstances with Newtype2 {
/**
* Actual implementation for [[cats.data.NonEmptyMap]]
*
* @note This object is kept public for the sake of binary compatibility only
* and therefore is subject to changes in future versions of Cats.
* Do not use directly - use [[cats.data.NonEmptyMap]] instead.
*/
object NonEmptyMapImpl extends NonEmptyMapInstances with Newtype2 {

private[data] def create[K, A](m: SortedMap[K, A]): Type[K, A] =
m.asInstanceOf[Type[K, A]]
Expand Down
13 changes: 11 additions & 2 deletions core/src/main/scala/cats/data/NonEmptySet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@ package data
import cats.kernel._

import scala.collection.immutable._

import kernel.compat.scalaVersionSpecific._

private[data] object NonEmptySetImpl extends NonEmptySetInstances with Newtype {
/**
* Actual implementation for [[cats.data.NonEmptySet]]
*
* @note This object is kept public for the sake of binary compatibility only
* and therefore is subject to changes in future versions of Cats.
* Do not use directly - use [[cats.data.NonEmptySet]] instead.
*/
object NonEmptySetImpl extends NonEmptySetInstances with Newtype {

private[data] def create[A](s: SortedSet[A]): Type[A] =
s.asInstanceOf[Type[A]]
Expand Down Expand Up @@ -433,7 +441,8 @@ sealed abstract private[data] class NonEmptySetInstances0 extends NonEmptySetIns
}

sealed abstract private[data] class NonEmptySetInstances1 {
private[data] def catsDataEqForNonEmptySet[A](implicit A: Order[A]): Eq[NonEmptySet[A]] =
@deprecated("use catsDataEqForNonEmptySetFromEqA instead", "2.8.0")
def catsDataEqForNonEmptySet[A](implicit A: Order[A]): Eq[NonEmptySet[A]] =
catsDataEqForNonEmptySetFromEqA[A]

implicit def catsDataEqForNonEmptySetFromEqA[A](implicit A: Eq[A]): Eq[NonEmptySet[A]] =
Expand Down

0 comments on commit 113da92

Please sign in to comment.