From bf2194c1df0354bf7a4a8792962f8d56a8b6b5df Mon Sep 17 00:00:00 2001 From: satorg Date: Wed, 1 Jun 2022 20:06:12 -0700 Subject: [PATCH] make NonEmptyChainImpl --- core/src/main/scala/cats/data/NonEmptyChain.scala | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/main/scala/cats/data/NonEmptyChain.scala b/core/src/main/scala/cats/data/NonEmptyChain.scala index 86a7db7befa..e6429ee9591 100644 --- a/core/src/main/scala/cats/data/NonEmptyChain.scala +++ b/core/src/main/scala/cats/data/NonEmptyChain.scala @@ -22,14 +22,12 @@ 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 { +private[data] object NonEmptyChainImpl extends NonEmptyChainImpl { // The following 3 types are components of a technique to // create a no-boxing newtype. It's copied from the // newtypes lib by @alexknvl @@ -44,6 +42,12 @@ private[data] object NonEmptyChainImpl extends NonEmptyChainInstances with Scala private[data] def unwrap[A](s: Type[A]): Chain[A] = s.asInstanceOf[Chain[A]] +} + +// This class has to be public to expose public methods to Mima. +@deprecated("for internal purposes only - do not use", "2.8.0") +sealed abstract class NonEmptyChainImpl extends NonEmptyChainInstances with ScalaVersionSpecificNonEmptyChainImpl { + self: NonEmptyChainImpl.type => def fromChain[A](as: Chain[A]): Option[NonEmptyChain[A]] = if (as.nonEmpty) Option(create(as)) else None @@ -83,10 +87,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.