Skip to content

Commit

Permalink
make scala 3 happy
Browse files Browse the repository at this point in the history
  • Loading branch information
ValdemarGr committed Jan 12, 2024
1 parent 198480a commit fadcfb2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,32 @@ package gql.server.interpreter
import cats._
import cats.implicits._
import gql.preparation._
import org.typelevel.scalaccompat.annotation._

object AlphaRenaming {
def alphaStep[F[_], A, B](scope: Int, step: PreparedStep[F, A, B]): Eval[PreparedStep[F, A, B]] = Eval.defer {
import PreparedStep._
step match {
case Lift(nid, a) => Eval.now(Lift(nid.alpha(scope), a))
case EmbedError(nid) => Eval.now(EmbedError(nid.alpha(scope)))
case GetMeta(nid, meta) => Eval.now(GetMeta(nid.alpha(scope), meta))
case alg: EmbedEffect[f, i] => Eval.now(EmbedEffect[f, i](alg.sei.alpha(scope)))
case alg: InlineBatch[f, k, v] => Eval.now(InlineBatch[f, k, v](alg.run, alg.sei.alpha(scope)))
case alg: Batch[f, k, v] => Eval.now(Batch[f, k, v](alg.id, alg.ubi.alpha(scope)))
case Compose(nid, l, r) => Eval.now(Compose(nid.alpha(scope), l, r))
case alg: Choose[f, i, a, b, c] =>
(alphaStep(scope, alg.fac), alphaStep(scope, alg.fbd)).mapN(Choose[f, i, a, b, c](alg.nodeId.alpha(scope), _, _))
case alg: First[f, i, a, b] => alphaStep(scope, alg.step).map(First[f, i, a, b](alg.nodeId.alpha(scope), _))
case alg: EmbedStream[f, i] => Eval.now(EmbedStream[f, i](alg.signal, alg.sei.alpha(scope)))
@nowarn3("msg=.*cannot be checked at runtime because its type arguments can't be determined.*")
def alphaStep[F[_], A, B](scope: Int, step: PreparedStep[F, A, B]): Eval[PreparedStep[F, A, B]] =
Eval.defer[PreparedStep[F, A, B]] {
import PreparedStep._
def now(fa: PreparedStep[F, A, B]): Eval[PreparedStep[F, A, B]] = Eval.now(fa)
step match {
case alg: EmbedEffect[f, b] => now(EmbedEffect[f, b](alg.sei.alpha(scope)))
case alg: Lift[F, A, B] => now(Lift[F, A, B](alg.nodeId.alpha(scope), alg.f))
case alg: EmbedError[F, B] => now(EmbedError[F, B](alg.nodeId.alpha(scope)))
case alg: GetMeta[f, a] => now(GetMeta[f, a](alg.nodeId.alpha(scope), alg.meta))
case alg: InlineBatch[F, k, v] => now(InlineBatch[F, k, v](alg.run, alg.sei.alpha(scope)))
case alg: Batch[F, k, v] => now(Batch[F, k, v](alg.id, alg.ubi.alpha(scope)))
case alg: Compose[F, A, a, B] =>
now(Compose[F, A, a, B](alg.nodeId.alpha(scope), alg.left, alg.right))
case alg: Choose[f, i, a, b, c] =>
(
alphaStep(scope, alg.fac),
alphaStep(scope, alg.fbd)
).mapN(Choose[f, i, a, b, c](alg.nodeId.alpha(scope), _, _))
case alg: First[f, i, a, b] => alphaStep(scope, alg.step).map(First[f, i, a, b](alg.nodeId.alpha(scope), _))
case alg: EmbedStream[f, i] => now(EmbedStream[f, i](alg.signal, alg.sei.alpha(scope)))
}
}
}

def alphaCont[F[_], A, B](scope: Int, cont: PreparedCont[F, A, B]): Eval[PreparedCont[F, A, B]] = Eval.defer {
(alphaStep(scope, cont.edges), alphaPrep(scope, cont.cont))
Expand All @@ -32,6 +40,7 @@ object AlphaRenaming {
alphaCont(scope, field.cont).map(cont => field.copy[F, A, B](cont = cont, nodeId = field.nodeId.alpha(scope)))
}

@nowarn3("msg=.*cannot be checked at runtime because its type arguments can't be determined.*")
def alphaField[F[_], A](scope: Int, field: PreparedField[F, A]): Eval[PreparedField[F, A]] = Eval.defer {
field match {
case pdf: PreparedDataField[F, A, b] => alphaDataField(scope, pdf)
Expand All @@ -42,7 +51,8 @@ object AlphaRenaming {
}
}

def alphaPrep[F[_], A](scope: Int, prep: Prepared[F, A]): Eval[Prepared[F, A]] = Eval.defer {
@nowarn3("msg=.*cannot be checked at runtime because its type arguments can't be determined.*")
def alphaPrep[F[_], A](scope: Int, prep: Prepared[F, A]): Eval[Prepared[F, A]] = Eval.defer[Prepared[F, A]] {
prep match {
case PreparedLeaf(nid, name, f) => Eval.now(PreparedLeaf(nid.alpha(scope), name, f))
case Selection(nodeId, fields, source) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gql.server.interpreter
import cats.effect.implicits._
import cats.data._
import gql._
import org.typelevel.scalaccompat.annotation._
import cats.effect._
import cats._
import cats.implicits._
Expand Down Expand Up @@ -45,6 +46,7 @@ object SubgraphBatches {
}
}

@nowarn3("msg=.*cannot be checked at runtime because its type arguments can't be determined.*")
def countStep[F[_]](state: State, step: PreparedStep[F, ?, ?]): Eval[State] = Eval.defer {
import PreparedStep._
step match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import cats.implicits._
import scala.concurrent.duration.FiniteDuration
import gql.resolver._
import io.circe.syntax._
import org.typelevel.scalaccompat.annotation._

import cats.effect.implicits._
final case class StreamData[F[_], I](
Expand Down Expand Up @@ -55,6 +56,7 @@ class SubqueryInterpreter[F[_]](
def submit(name: String, duration: FiniteDuration, size: Int): F[Unit] =
sup.supervise(stats.updateStats(name, duration, size)).void

@nowarn3("msg=.*cannot be checked at runtime because its type arguments can't be determined.*")
def interpretSelection[I](
fields: List[PreparedField[F, I]],
en: EvalNode[F, I]
Expand All @@ -72,6 +74,7 @@ class SubqueryInterpreter[F[_]](
}
}

@nowarn3("msg=.*cannot be checked at runtime because its type arguments can't be determined.*")
def interpretPrepared[I](
s: Prepared[F, I],
en: EvalNode[F, I]
Expand All @@ -96,6 +99,7 @@ class SubqueryInterpreter[F[_]](
}
}

@nowarn3("msg=.*cannot be checked at runtime because its type arguments can't be determined.*")
def goCont[I](
c: Continuation[F, I],
en: EvalNode[F, I]
Expand All @@ -106,6 +110,7 @@ class SubqueryInterpreter[F[_]](
case fa: Continuation.Contramap[F, i, I] => goCont(fa.next, en.map(fa.f))
}

@nowarn3("msg=.*cannot be checked at runtime because its type arguments can't be determined.*")
def goStep[I, O](
ps: PreparedStep[F, I, O],
cont: Continuation[F, O],
Expand Down

0 comments on commit fadcfb2

Please sign in to comment.