Skip to content
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

Swap ? placeholder and _ wildcard using kind-projector 0.13.0 & scalac 2.13.6 #1479

Merged
merged 20 commits into from
May 29, 2021
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
588 changes: 360 additions & 228 deletions build.sbt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object QuasiIORunner {

def fromCats[F[_]: Effect]: QuasiIORunner[F] = forAny[F]

class BIOImpl[F[_, _]] extends QuasiIORunner[F[Throwable, ?]]
class BIOImpl[F[_, _]] extends QuasiIORunner[F[Throwable, _]]

implicit def forAny[F[_]]: QuasiIORunner[F] = new QuasiIORunner[F] {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package izumi.distage.model.reflection
import izumi.fundamentals.reflection.TypeUtil

trait MirrorProvider {
def runtimeClass(tpe: SafeType): Option[Class[_]]
def runtimeClass(tpe: SafeType): Option[Class[?]]
def runtimeClassCompatible(tpe: SafeType, value: Any): Boolean
def canBeProxied(tpe: SafeType): Boolean
}

object MirrorProvider {
object Impl extends MirrorProvider {
override def runtimeClass(tpe: SafeType): Option[Class[_]] = {
override def runtimeClass(tpe: SafeType): Option[Class[?]] = {
if (tpe.hasPreciseClass) Some(tpe.cls) else None
}
override def canBeProxied(tpe: SafeType): Boolean = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ object QuasiIORunner extends LowPriorityQuasiIORunnerInstances {
override def run[A](f: => A): A = f
}

implicit def fromBIO[F[_, _]: UnsafeRun2]: QuasiIORunner[F[Throwable, ?]] = new BIOImpl[F]
implicit def fromBIO[F[_, _]: UnsafeRun2]: QuasiIORunner[F[Throwable, _]] = new BIOImpl[F]

final class BIOImpl[F[_, _]: UnsafeRun2] extends QuasiIORunner[F[Throwable, ?]] {
final class BIOImpl[F[_, _]: UnsafeRun2] extends QuasiIORunner[F[Throwable, _]] {
override def run[A](f: => F[Throwable, A]): A = UnsafeRun2[F].unsafeRun(f)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import java.lang.reflect.Modifier
import izumi.fundamentals.reflection.TypeUtil

trait MirrorProvider {
def runtimeClass(tpe: SafeType): Option[Class[_]]
def runtimeClass(tpe: SafeType): Option[Class[?]]
def runtimeClassCompatible(tpe: SafeType, value: Any): Boolean
def canBeProxied(tpe: SafeType): Boolean
}

object MirrorProvider {
object Impl extends MirrorProvider {
override def runtimeClass(tpe: SafeType): Option[Class[_]] = {
override def runtimeClass(tpe: SafeType): Option[Class[?]] = {
if (tpe.hasPreciseClass) Some(tpe.cls) else None
}
override def canBeProxied(tpe: SafeType): Boolean = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ object AnyConstructorMacro {
assert(enclosingClass.exists(_.pos == positionOfMakeCall), "enclosingClass must contain macro call position")

def findExprContainingMake(tree: Tree): Option[Tree] = {
@nowarn("msg=outer reference")
val afterLastBlock = Option {
tree
.filter(_.exists(_.pos == positionOfMakeCall))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import izumi.distage.model.reflection.universe.StaticDIUniverse
import izumi.distage.reflection.ReflectionProviderDefaultImpl
import izumi.fundamentals.reflection.{ReflectionUtil, TrivialMacroLogger}

import scala.annotation.nowarn
import scala.reflect.macros.blackbox

object ClassConstructorMacro {
Expand All @@ -16,7 +17,7 @@ object ClassConstructorMacro {
val targetType = ReflectionUtil.norm(c.universe: c.universe.type)(weakTypeOf[T].dealias)
requireConcreteTypeConstructor(c)("ClassConstructor", targetType)

targetType match {
(targetType match {
case t: SingletonTypeApi =>
val functoid = symbolOf[Functoid.type].asClass.module
val term = t match {
Expand Down Expand Up @@ -49,7 +50,7 @@ object ClassConstructorMacro {
val res = c.Expr[ClassConstructor[T]](q"{ new ${weakTypeOf[ClassConstructor[T]]}($provider) }")
logger.log(s"Final syntax tree of class for $targetType:\n$res")
res
}
}): @nowarn("msg=outer reference")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import izumi.distage.model.reflection.universe.StaticDIUniverse
import izumi.distage.model.reflection.{Provider, ReflectionProvider}
import izumi.fundamentals.reflection.ReflectionUtil

import scala.annotation.tailrec
import scala.annotation.{nowarn, tailrec}
import scala.reflect.macros.blackbox

abstract class ClassConstructorMacros extends ConstructorMacrosBase {
Expand Down Expand Up @@ -115,6 +115,7 @@ abstract class FactoryConstructorMacros extends ConstructorMacrosBase {
val u.Wiring.Factory.FactoryMethod(factoryMethod, productConstructor, _) = factoryMethod0

val (methodArgListDecls, methodArgList) = {
@nowarn("msg=outer reference")
@tailrec def instantiatedMethod(tpe: Type): MethodTypeApi = {
tpe match {
case m: MethodTypeApi => m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ object PlannerInput {
*
* Effectively, this selects and creates a *sub-graph* of the largest possible object graph that can be described by `bindings`
*/
def apply(bindings: ModuleBase, activation: Activation, roots: NonEmptySet[_ <: DIKey]): PlannerInput = PlannerInput(bindings, activation, Roots(roots))
def apply(bindings: ModuleBase, activation: Activation, roots: NonEmptySet[? <: DIKey]): PlannerInput = PlannerInput(bindings, activation, Roots(roots))

/**
* Instantiate `roots` and the dependencies of `roots`, discarding bindings that are unrelated.
*
* Effectively, this selects and creates a *sub-graph* of the largest possible object graph that can be described by `bindings`
*/
def apply(bindings: ModuleBase, activation: Activation, roots: Set[_ <: DIKey])(implicit d: DummyImplicit): PlannerInput =
def apply(bindings: ModuleBase, activation: Activation, roots: Set[? <: DIKey])(implicit d: DummyImplicit): PlannerInput =
PlannerInput(bindings, activation, Roots(roots))

/** Instantiate `root`, `roots` and their dependencies, discarding bindings that are unrelated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,12 @@ object Lifecycle extends LifecycleCatsInstances {
*
* @return The [[izumi.functional.bio.Fiber2 fiber]] running `f` action
*/
def fork[F[+_, +_]: Fork2, E, A](f: F[E, A]): Lifecycle[F[Nothing, ?], Fiber2[F, E, A]] = {
def fork[F[+_, +_]: Fork2, E, A](f: F[E, A]): Lifecycle[F[Nothing, _], Fiber2[F, E, A]] = {
Lifecycle.make(f.fork)(_.interrupt)
}

/** @see [[fork]] */
def fork_[F[+_, +_]: Fork2: Functor2, E, A](f: F[E, A]): Lifecycle[F[Nothing, ?], Unit] = {
def fork_[F[+_, +_]: Fork2: Functor2, E, A](f: F[E, A]): Lifecycle[F[Nothing, _], Unit] = {
Lifecycle.fork(f).void
}

Expand Down Expand Up @@ -440,8 +440,8 @@ object Lifecycle extends LifecycleCatsInstances {
}
}

implicit final class SyntaxWidenError[F[+_, +_], +E, +A](private val resource: Lifecycle[F[E, ?], A]) extends AnyVal {
def widenError[E1 >: E]: Lifecycle[F[E1, ?], A] = resource
implicit final class SyntaxWidenError[F[+_, +_], +E, +A](private val resource: Lifecycle[F[E, _], A]) extends AnyVal {
def widenError[E1 >: E]: Lifecycle[F[E1, _], A] = resource
}

/** Convert [[cats.effect.Resource]] to [[Lifecycle]] */
Expand Down Expand Up @@ -539,7 +539,7 @@ object Lifecycle extends LifecycleCatsInstances {
}
}

implicit final class SyntaxLifecycleZIO[-R, +E, +A](private val resource: Lifecycle[ZIO[R, E, ?], A]) extends AnyVal {
implicit final class SyntaxLifecycleZIO[-R, +E, +A](private val resource: Lifecycle[ZIO[R, E, _], A]) extends AnyVal {
/** Convert [[Lifecycle]] to [[zio.ZManaged]] */
def toZIO: ZManaged[R, E, A] = {
ZManaged.makeReserve(
Expand All @@ -558,12 +558,12 @@ object Lifecycle extends LifecycleCatsInstances {
}
}

implicit final def functor2ForLifecycle[F[+_, +_]: Functor2]: Functor2[Lifecycle2[F, +?, +?]] = new Functor2[Lifecycle2[F, +?, +?]] {
override def map[R, E, A, B](r: Lifecycle[F[E, ?], A])(f: A => B): Lifecycle[F[E, ?], B] = r.map(f)
implicit final def functor2ForLifecycle[F[+_, +_]: Functor2]: Functor2[Lifecycle2[F, +_, +_]] = new Functor2[Lifecycle2[F, +_, +_]] {
override def map[R, E, A, B](r: Lifecycle[F[E, _], A])(f: A => B): Lifecycle[F[E, _], B] = r.map(f)
}

implicit final def functor3ForLifecycle[F[-_, +_, +_]: Functor3]: Functor3[Lifecycle3[F, -?, +?, +?]] = new Functor3[Lifecycle3[F, -?, +?, +?]] {
override def map[R, E, A, B](r: Lifecycle[F[R, E, ?], A])(f: A => B): Lifecycle[F[R, E, ?], B] = r.map(f)
implicit final def functor3ForLifecycle[F[-_, +_, +_]: Functor3]: Functor3[Lifecycle3[F, -_, +_, +_]] = new Functor3[Lifecycle3[F, -_, +_, +_]] {
override def map[R, E, A, B](r: Lifecycle[F[R, E, _], A])(f: A => B): Lifecycle[F[R, E, _], B] = r.map(f)
}

/**
Expand Down Expand Up @@ -623,7 +623,7 @@ object Lifecycle extends LifecycleCatsInstances {
* }
* }}}
*/
@open class OfZIO[-R, +E, +A](inner: => ZManaged[R, E, A]) extends Lifecycle.Of[ZIO[R, E, ?], A](fromZIO(inner))
@open class OfZIO[-R, +E, +A](inner: => ZManaged[R, E, A]) extends Lifecycle.Of[ZIO[R, E, _], A](fromZIO(inner))

/**
* Class-based variant of [[make]]:
Expand Down Expand Up @@ -803,7 +803,7 @@ object Lifecycle extends LifecycleCatsInstances {
override final type InnerResource = concurrent.Ref[F, List[ExitCase[Throwable] => F[Unit]]]
}

trait FromZIO[R, E, A] extends Lifecycle[ZIO[R, E, ?], A] {
trait FromZIO[R, E, A] extends Lifecycle[ZIO[R, E, _], A] {
override final type InnerResource = ReleaseMap
override final def acquire: ZIO[R, E, ReleaseMap] = ReleaseMap.make
override final def release(releaseMap: ReleaseMap): ZIO[R, Nothing, Unit] = releaseMap.releaseAll(zio.Exit.succeed(()), zio.ExecutionStrategy.Sequential).unit
Expand Down Expand Up @@ -1062,11 +1062,11 @@ object Lifecycle extends LifecycleCatsInstances {
private[definition] sealed trait LifecycleCatsInstances extends LifecycleCatsInstancesLowPriority {
implicit final def catsMonadForLifecycle[Monad[_[_]]: `cats.Monad`, F[_]](
implicit F: QuasiIO[F]
): Monad[Lifecycle[F, ?]] = {
new cats.StackSafeMonad[Lifecycle[F, ?]] {
): Monad[Lifecycle[F, _]] = {
new cats.StackSafeMonad[Lifecycle[F, _]] {
override def pure[A](x: A): Lifecycle[F, A] = Lifecycle.pure[F](x)
override def flatMap[A, B](fa: Lifecycle[F, A])(f: A => Lifecycle[F, B]): Lifecycle[F, B] = fa.flatMap(f)
}.asInstanceOf[Monad[Lifecycle[F, ?]]]
}.asInstanceOf[Monad[Lifecycle[F, _]]]
}

implicit final def catsMonoidForLifecycle[Monoid[_]: `cats.kernel.Monoid`, F[_], A](
Expand All @@ -1090,10 +1090,10 @@ private[definition] sealed trait LifecycleCatsInstances extends LifecycleCatsIns
private[definition] sealed trait LifecycleCatsInstancesLowPriority {
implicit final def catsFunctorForLifecycle[F[_], Functor[_[_]]: `cats.Functor`](
implicit F: QuasiFunctor[F]
): Functor[Lifecycle[F, ?]] = {
new cats.Functor[Lifecycle[F, ?]] {
): Functor[Lifecycle[F, _]] = {
new cats.Functor[Lifecycle[F, _]] {
override def map[A, B](fa: Lifecycle[F, A])(f: A => B): Lifecycle[F, B] = fa.map(f)
}.asInstanceOf[Functor[Lifecycle[F, ?]]]
}.asInstanceOf[Functor[Lifecycle[F, _]]]
}
}

Expand Down Expand Up @@ -1228,22 +1228,22 @@ private[definition] trait TrifunctorHasLifecycleTagImpl[R0, T] {
type E
type A <: T
implicit def tagLocal3: Tag[Local3[F]]
implicit def tagFull: Tag[Lifecycle[F[Any, E, ?], A]]
implicit def tagFull: Tag[Lifecycle[F[Any, E, _], A]]
implicit def ctorR: HasConstructor[R]
implicit def ev: R0 <:< Lifecycle[F[R, E, ?], A]
implicit def resourceTag: LifecycleTagImpl[Lifecycle[F[Any, E, ?], A]]
implicit def ev: R0 <:< Lifecycle[F[R, E, _], A]
implicit def resourceTag: LifecycleTagImpl[Lifecycle[F[Any, E, _], A]]
}
private[definition] object TrifunctorHasLifecycleTagImpl extends TrifunctorHasLifecycleTagLowPriority {
import scala.annotation.unchecked.{uncheckedVariance => v}

implicit def trifunctorResourceTag[
R1 <: Lifecycle[F0[R0, E0, ?], A0],
R1 <: Lifecycle[F0[R0, E0, _], A0],
F0[_, _, _]: TagK3,
R0: HasConstructor,
E0: Tag,
A0 <: A1: Tag,
A1,
]: TrifunctorHasLifecycleTagImpl[R1 with Lifecycle[F0[R0, E0, ?], A0], A1] {
]: TrifunctorHasLifecycleTagImpl[R1 with Lifecycle[F0[R0, E0, _], A0], A1] {
type R = R0
type E = E0
type A = A0
Expand All @@ -1255,13 +1255,13 @@ private[definition] object TrifunctorHasLifecycleTagImpl extends TrifunctorHasLi
type A = A0
val tagLocal3: Tag[Local3[F]] = implicitly
val ctorR: HasConstructor[R0] = implicitly
val tagFull: Tag[Lifecycle[F0[Any, E0, ?], A0]] = implicitly
val ev: R1 <:< Lifecycle[F0[R0, E0, ?], A0] = implicitly
val resourceTag: LifecycleTagImpl[Lifecycle[F0[Any, E0, ?], A0]] = new LifecycleTagImpl[Lifecycle[F0[Any, E0, ?], A0]] {
val tagFull: Tag[Lifecycle[F0[Any, E0, _], A0]] = implicitly
val ev: R1 <:< Lifecycle[F0[R0, E0, _], A0] = implicitly
val resourceTag: LifecycleTagImpl[Lifecycle[F0[Any, E0, _], A0]] = new LifecycleTagImpl[Lifecycle[F0[Any, E0, _], A0]] {
type F[AA] = F0[Any, E0, AA]
type A = A0
val tagFull: Tag[Lifecycle[F0[Any, E0, ?], A0]] = self.tagFull
val tagK: TagK[F0[Any, E0, ?]] = TagK[F0[Any, E0, ?]]
val tagFull: Tag[Lifecycle[F0[Any, E0, _], A0]] = self.tagFull
val tagK: TagK[F0[Any, E0, _]] = TagK[F0[Any, E0, _]]
val tagA: Tag[A0] = implicitly
}
}
Expand All @@ -1270,12 +1270,12 @@ sealed trait TrifunctorHasLifecycleTagLowPriority extends TrifunctorHasLifecycle
import scala.annotation.unchecked.{uncheckedVariance => v}

implicit def trifunctorResourceTagNothing[
R1 <: Lifecycle[F0[R0, Nothing, ?], A0],
R1 <: Lifecycle[F0[R0, Nothing, _], A0],
F0[_, _, _]: TagK3,
R0: HasConstructor,
A0 <: A1: Tag,
A1,
]: TrifunctorHasLifecycleTagImpl[R1 with Lifecycle[F0[R0, Nothing, ?], A0], A1] {
]: TrifunctorHasLifecycleTagImpl[R1 with Lifecycle[F0[R0, Nothing, _], A0], A1] {
type R = R0
type E = Nothing
type A = A0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ object LocatorDef {
addOp(SetImpl(impl))(new BindDSLUnnamedAfterFrom[T](_, key))
}

final class BindNamedDSL[T](protected val mutableState: SingletonRef, protected val key: DIKey.IdKey[_])
final class BindNamedDSL[T](protected val mutableState: SingletonRef, protected val key: DIKey.IdKey[?])
extends BindDSLBase[T, BindDSLNamedAfterFrom[T]]
with BindDSLMutBase[T] {
override protected def bind(impl: ImplDef): BindDSLNamedAfterFrom[T] =
Expand All @@ -109,7 +109,7 @@ object LocatorDef {
addOp(SetId(name))(new BindNamedDSL[T](_, key.named(name)))
}

final class BindDSLNamedAfterFrom[T](override protected val mutableState: SingletonRef, override protected val key: DIKey.IdKey[_]) extends BindDSLMutBase[T]
final class BindDSLNamedAfterFrom[T](override protected val mutableState: SingletonRef, override protected val key: DIKey.IdKey[?]) extends BindDSLMutBase[T]
final class BindDSLAfterAlias[T](override protected val mutableState: SingletonRef, override protected val key: DIKey) extends BindDSLMutBase[T]

sealed trait BindDSLMutBase[T] {
Expand Down
Loading