8000 Make `*VersionSpecific` and `*PlatformSpecific` traits package-private by kyri-petrou · Pull Request #9491 · zio/zio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make *VersionSpecific and *PlatformSpecific traits package-private #9491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ import scala.annotation.implicitAmbiguous
*
* Based on https://github.com/milessabin/shapeless.
*/
abstract class =!=[A, B] extends Serializable
sealed abstract class =!=[A, B] extends Serializable

object =!= {
private val instance: =!=[Any, Any] = new =!=[Any, Any] {}

def unexpected: Nothing = sys.error("Unexpected invocation")

implicit def neq[A, B]: A =!= B = new =!=[A, B] {}
implicit def neq[A, B]: A =!= B = instance.asInstanceOf[=!=[A, B]]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱


@implicitAmbiguous("Cannot prove that ${A} =!= ${A}")
implicit def neqAmbig1[A]: A =!= A = unexpected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package zio

import zio.internal.macros.IsReloadableMacros

trait IsReloadableVersionSpecific {
private[zio] trait IsReloadableVersionSpecific {

/**
* Generates a proxy instance of the specified service.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package zio

trait TagVersionSpecific {
private[zio] trait TagVersionSpecific {
implicit def materialize[A]: Tag[A] =
macro zio.internal.macros.InternalMacros.materializeTag[A]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package zio

trait ZIOAppVersionSpecific {
private[zio] trait ZIOAppVersionSpecific {

/**
* This implicit conversion macro will ensure that the provided ZIO effect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import zio.stacktracer.TracingImplicits.disableAutoTrace

import java.io.IOException

trait ZIOCompanionVersionSpecific {
private[zio] trait ZIOCompanionVersionSpecific {

/**
* Converts an asynchronous, callback-style API into a ZIO effect, which will
Expand Down
8 changes: 5 additions & 3 deletions core/shared/src/main/scala-3/zio/=!=.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ package zio

import zio.stacktracer.TracingImplicits.disableAutoTrace

import scala.annotation.implicitNotFound
import scala.annotation.{implicitNotFound, static}
import scala.util.NotGiven

/**
* Evidence type `A` is not equal to type `B`.
*/
@implicitNotFound("${A} must not be ${B}")
abstract class =!=[A, B] extends Serializable
sealed abstract class =!=[A, B] extends Serializable

object =!= {
implicit def neq[A, B](implicit ev: NotGiven[A =:= B]): A =!= B = new =!=[A, B] {}
@static private val instance: =!=[Any, Any] = new =!=[Any, Any] {}

given neq[A, B](using NotGiven[A =:= B]): =!=[A, B] = instance.asInstanceOf[=!=[A, B]]
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package zio
import scala.annotation.experimental
import scala.quoted.*

transparent trait IsReloadableVersionSpecific {
private[zio] transparent trait IsReloadableVersionSpecific {

/**
* Generates a proxy instance of the specified service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package zio

import scala.quoted.*

transparent trait TagVersionSpecific {
private[zio] transparent trait TagVersionSpecific {
transparent inline def derived[A]: Tag[A] =
${ TagMacros.materialize[A] }

Expand Down
6 changes: 3 additions & 3 deletions core/shared/src/main/scala-3/zio/ZIOAppVersionSpecific.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package zio
import scala.quoted._
import zio.internal.TerminalRendering

transparent trait ZIOAppVersionSpecific {
private[zio] transparent trait ZIOAppVersionSpecific {

/**
* This implicit conversion macro will ensure that the provided ZIO effect
Expand All @@ -17,12 +17,12 @@ transparent trait ZIOAppVersionSpecific {

}

object ZIOAppVersionSpecificMacros {
private[zio] object ZIOAppVersionSpecificMacros {
def validate[Provided: Type, Required: Type, E: Type, A: Type](zio: Expr[ZIO[Required, E, A]])(using ctx: Quotes) =
new ZIOAppVersionSpecificMacros(ctx).validate[Provided, Required, E, A](zio)
}

class ZIOAppVersionSpecificMacros(val ctx: Quotes) {
private[zio] class ZIOAppVersionSpecificMacros(val ctx: Quotes) {
given Quotes = ctx
import ctx.reflect._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import zio.stacktracer.TracingImplicits.disableAutoTrace
import java.io.IOException
import scala.annotation.targetName

transparent trait ZIOCompanionVersionSpecific {
private[zio] transparent trait ZIOCompanionVersionSpecific {

/**
* Converts an asynchronous, callback-style API into a ZIO effect, which will
Expand Down Expand Up @@ -210,12 +210,12 @@ transparent trait ZIOCompanionVersionSpecific {

@targetName("succeed")
@deprecated("use succeed", "2.1.7")
def _succeedCompat[A](a: Unsafe ?=> A)(implicit trace: Trace): ZIO[Any, Nothing, A] =
private[zio] def _succeedCompat[A](a: Unsafe ?=> A)(implicit trace: Trace): ZIO[Any, Nothing, A] =
succeed(a)

@targetName("succeedBlocking")
@deprecated("use succeedBlocking", "2.1.7")
56D8 def _succeedBlockingCompat[A](a: Unsafe ?=> A)(implicit trace: Trace): UIO[A] =
private[zio] def _succeedBlockingCompat[A](a: Unsafe ?=> A)(implicit trace: Trace): UIO[A] =
ZIO.blocking(ZIO.succeed(a))

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class WireSomePartiallyApplied[R0, R](val dummy: Boolean = true) extends A
${ LayerMacros.constructLayer[R0, R, E]('layer) }
}

transparent trait ZLayerCompanionVersionSpecific {
private[zio] transparent trait ZLayerCompanionVersionSpecific {

/**
* Automatically assembles a layer for the provided type.
Expand Down
8 changes: 4 additions & 4 deletions core/shared/src/main/scala/zio/VersionSpecific.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ import java.util.concurrent.ConcurrentHashMap
private[zio] trait VersionSpecific {

type EnvironmentTag[A] = izumi.reflect.Tag[A]
lazy val EnvironmentTag = izumi.reflect.Tag
val EnvironmentTag = izumi.reflect.Tag

type TagK[F[_]] = izumi.reflect.TagK[F]
lazy val TagK = izumi.reflect.TagK
val TagK = izumi.reflect.TagK

type TagKK[F[_, _]] = izumi.reflect.TagKK[F]
lazy val TagKK = izumi.reflect.TagKK
val TagKK = izumi.reflect.TagKK

type TagK3[F[_, _, _]] = izumi.reflect.TagK3[F]
lazy val TagK3 = izumi.reflect.TagK3
val TagK3 = izumi.reflect.TagK3

type TagK4[F[_, _, _, _]] = izumi.reflect.TagK4[F]
type TagK5[F[_, _, _, _, _]] = izumi.reflect.TagK5[F]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import zio._

import zio.internal.macros.LayerMacros

trait ZManagedVersionSpecific[-R, +E, +A] { self: ZManaged[R, E, A] =>
private[managed] trait ZManagedVersionSpecific[-R, +E, +A] { self: ZManaged[R, E, A] =>

/**
* Splits the environment into two parts, assembling one part using the
Expand Down
2 changes: 1 addition & 1 deletion streams/js/src/main/scala/zio/stream/platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private[stream] trait ZStreamPlatformSpecificConstructors {
)(implicit trace: Trace): ZStream[R, E, A] =
asyncInterrupt(k => register(k).toRight(ZIO.unit), outputBuffer)

trait ZStreamConstructorPlatformSpecific extends ZStreamConstructorLowPriority1
private[stream] trait ZStreamConstructorPlatformSpecific extends ZStreamConstructorLowPriority1

def fromFile(file: => String, chunkSize: => Int = ZStream.DefaultChunkSize)(implicit
trace: Trace
Expand Down
2 changes: 1 addition & 1 deletion streams/jvm/src/main/scala/zio/stream/platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ private[stream] trait ZStreamPlatformSpecificConstructors {
ZIO.acquireRelease(ZIO.succeed(new Connection(socket)))(_.close())
}

trait ZStreamConstructorPlatformSpecific extends ZStreamConstructorLowPriority1 {
private[stream] trait ZStreamConstructorPlatformSpecific extends ZStreamConstructorLowPriority1 {

/**
* Constructs a `ZStream[Any, Throwable, A]` from a
Expand Down
2 changes: 1 addition & 1 deletion streams/native/src/main/scala/zio/stream/platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ private[stream] trait ZStreamPlatformSpecificConstructors {
): ZStream[R, Throwable, A] =
ZStream.fromZIO(stream).flatMap(ZStream.fromJavaStream(_, chunkSize))

trait ZStreamConstructorPlatformSpecific extends ZStreamConstructorLowPriority1 {
private[stream] trait ZStreamConstructorPlatformSpecific extends ZStreamConstructorLowPriority1 {

/**
* Constructs a `ZStream[Any, Throwable, A]` from a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package zio.stream
import zio.ZLayer
import zio.internal.macros.LayerMacros

trait ZStreamVersionSpecific[-R, +E, +O] { self: ZStream[R, E, O] =>
private[stream] trait ZStreamVersionSpecific[-R, +E, +O] { self: ZStream[R, E, O] =>

/**
* Automatically assembles a layer for the ZStream effect, which translates it
Expand All @@ -14,7 +14,7 @@ trait ZStreamVersionSpecific[-R, +E, +O] { self: ZStream[R, E, O] =>

}

object ZStreamProvideMacro {
private[stream] object ZStreamProvideMacro {
import scala.quoted._

def provideImpl[R0: Type, R: Type, E: Type, A: Type](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ package zio.test

import zio.stacktracer.TracingImplicits.disableAutoTrace

trait FieldExtractorPlatformSpecific {
private[test] trait FieldExtractorPlatformSpecific {
def productFields(obj: Product): Iterator[String] = Iterator.fill(obj.productArity)("")
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package zio.test
import zio.stacktracer.TracingImplicits.disableAutoTrace
import zio.{Duration, Scheduler, Trace, UIO, Unsafe, ZIO}

trait TestClockPlatformSpecific { self: TestClock.Test =>
private[test] trait TestClockPlatformSpecific { self: TestClock.Test =>

def scheduler(implicit trace: Trace): UIO[Scheduler] =
ZIO.runtime[Any].map { runtime =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ package zio.test

import zio.stacktracer.TracingImplicits.disableAutoTrace

trait FieldExtractorPlatformSpecific {
private[test] trait FieldExtractorPlatformSpecific {
def productFields(obj: Product): Iterator[String] = obj.getClass.getDeclaredFields.iterator.map(_.getName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ package zio.test

import zio.stacktracer.TracingImplicits.disableAutoTrace

trait FieldExtractorPlatformSpecific {
private[test] trait FieldExtractorPlatformSpecific {
def productFields(obj: Product): Iterator[String] = Iterator.fill(obj.productArity)("")
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package zio.test

import zio.stacktracer.TracingImplicits.disableAutoTrace

trait PrettyPrintVersionSpecific {
private[test] trait PrettyPrintVersionSpecific {
def labels(product: Product): Iterator[String] = {
val _ = product
Iterator.continually("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package zio.test

import zio.stacktracer.TracingImplicits.disableAutoTrace

trait PrettyPrintVersionSpecific {
private[test] trait PrettyPrintVersionSpecific {
def labels(product: Product): Iterator[String] = product.productElementNames
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package zio.test

import zio.{EnvironmentTag, Tag, Trace, ZLayer}
import zio.ZLayer
import zio.internal.macros.LayerMacros

private[test] trait SpecVersionSpecific[-R, +E] { self: Spec[R, E] =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package zio.test

trait ZIOSpecAbstractVersionSpecific {
private[test] trait ZIOSpecAbstractVersionSpecific {

/**
* This implicit conversion macro will ensure that the provided ZIO effect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package zio.test

trait ZIOSpecVersionSpecific[R] {
private[test] trait ZIOSpecVersionSpecific[R] {
// SCALA 2

def suiteAll(name: String)(spec: Any): Spec[Nothing, Any] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package zio.test

import zio.stacktracer.TracingImplicits.disableAutoTrace

trait PrettyPrintVersionSpecific {
private[test] trait PrettyPrintVersionSpecific {
def labels(product: Product): Iterator[String] = product.productElementNames
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package zio.test

import zio.{ZIO, ZLayer}

trait SpecVersionSpecific[-R, +E] { self: Spec[R, E] =>
private[test] trait SpecVersionSpecific[-R, +E] { self: Spec[R, E] =>

/**
* Automatically assembles a layer for the spec, translating it up a level.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package zio.test
import scala.quoted._
import zio.internal.TerminalRendering

trait ZIOSpecAbstractVersionSpecific {
private[test] trait ZIOSpecAbstractVersionSpecific {

/**
* This implicit conversion macro will ensure that the provided ZIO effect
Expand All @@ -17,12 +17,12 @@ trait ZIOSpecAbstractVersionSpecific {

}

object ZIOSpecAbstractSpecificMacros {
private[test] object ZIOSpecAbstractSpecificMacros {
def validate[Provided: Type, Required: Type, E: Type](spec: Expr[Spec[Required, E]])(using ctx: Quotes) =
new ZIOSpecAbstractSpecificMacros(ctx).validate[Provided, Required, E](spec)
}

class ZIOSpecAbstractSpecificMacros(val ctx: Quotes) {
private[test] class ZIOSpecAbstractSpecificMacros(val ctx: Quotes) {
given Quotes = ctx
import ctx.reflect._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package zio.test

import scala.quoted.*

trait ZIOSpecVersionSpecific[R] { self: ZIOSpec[R] =>
private[test] trait ZIOSpecVersionSpecific[R] { self: ZIOSpec[R] =>

transparent inline def suiteAll(inline name: String)(inline spec: Any): Any =
${ ZIOSpecVersionSpecificMacros.suiteAllImpl('name, 'spec) }

}

object ZIOSpecVersionSpecificMacros {
private[test] object ZIOSpecVersionSpecificMacros {

def suiteAllImpl(name: Expr[String], spec: Expr[Any])(using ctx: Quotes) = {
import ctx.reflect._
Expand Down
Loading
0