-
Notifications
You must be signed in to change notification settings - Fork 1.1k
compilation result depends on order of definition of context parameters #23118
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
Comments
I am not sure, maybe it is Cats and/or Cats Effect issues - something with monad types and their priorities? UPDATE: I created Cats Effect issue too: typelevel/cats-effect#4401 |
Minimization without depending on Cats Effect would help to diagnose. |
A different minimization with cats (I used scala 2 compatible syntax to check if it would work in scala 2 but there it fails in even more cases) //> using dep org.typelevel::cats-effect:3.6.1
import cats.Parallel
import cats.effect.{Async, IO, Resource}
object FailF {
def make1[F[_]](implicit a: Async[F]): Resource[F, Unit] = ???
def make2[F[_]](implicit p: Parallel[F]): Resource[F, Unit] = ???
def make3[F[_]](implicit p: Parallel[F], a: Async[F]): Resource[F, Unit] = ???
}
object Fail {
def noMap1(): Resource[IO, Unit] = FailF.make1
def noMap2(): Resource[IO, Unit] = FailF.make2
def noMap3(): Resource[IO, Unit] = FailF.make3
def withMap1(): Resource[IO, Unit] = FailF.make1.map(x => x)
def withMap2(): Resource[IO, Unit] = FailF.make2.map(x => x)
def withMap3(): Resource[IO, Unit] = FailF.make3.map(x => x)
} In scala 3.7.0 only |
It seems like I managed to minimize this without an external dependency: sealed abstract class Resource[F[_], +A] {
def map[B](f: A => B): Resource[F, B] = ???
}
trait Semigroup[A]
object Semigroup {
implicit def instanceInt: Semigroup[Int] = ???
implicit def instanceString: Semigroup[String] = ???
}
trait Parallel[M[_]] {
type F[_]
}
object Parallel {
type Aux[M[_], F0[_]] = Parallel[M] { type F[x] = F0[x] }
implicit def fromSemigroup[E](implicit s: Semigroup[E]): Parallel.Aux[Option, Option] = ???
}
trait Async[F[_]]
class IO[+A]
object IO {
implicit def asyncForIO: Async[IO] = ???
implicit def parallelForIO: Parallel.Aux[IO, IO] = ???
}
object Fail {
def make1[F[_]](implicit a: Async[F]): Resource[F, Unit] = ???
def make2[F[_]](implicit p: Parallel[F]): Resource[F, Unit] = ???
def make3[F[_]](implicit p: Parallel[F], a: Async[F]): Resource[F, Unit] = ???
def make4[F[_]](implicit a: Async[F], p: Parallel[F]): Resource[F, Unit] = ???
def test1(): Resource[IO, Unit] = make1.map(x => x) // error
def test2(): Resource[IO, Unit] = make2.map(x => x) // OK
def test3(): Resource[IO, Unit] = make3.map(x => x) // OK
def test4(): Resource[IO, Unit] = make4.map(x => x) // error
} Interestingly, the existence of |
Compiler version
3.7.0, 3.6.4
Minimized code
Code is using Cats Effect 3.5.4
Output
Expectation
Compilation should succeed also with
{ Async, Parallel }
.The text was updated successfully, but these errors were encountered: