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
F[*] != F #9566
Comments
This is a tentative fix for scala#9566: if a type variable has a lower bound more precise than Nothing, then further constraints can only restrict its set of members, so there's no unknown members (...but the set of members actually present is unknown, I think that's OK here but I should rename that method and/or clarify the docs).
Let's revisit this once we have a minimization. |
I'd like to keep this open since I'm working on a fix for it, I have a sort-of-minimization for it: import cats._
import cats.syntax.all.toFunctorOps
trait R[+M[_], +A] { def allocated[G[x] >: M[x]](implicit G: Functor[G]): G[G[Unit]] }
object Test {
def error[F[_], A](r: R[F, A])(implicit F: Functor[F]) = {
r.allocated(using F).void // error with dotty, works with scala 2
}
}
|
Here's a self-contained example (derived from the cats-effect codebase at the commit in the original post) where trait Applicative[F[_]]
trait IO[+A]
object IO {
def apply[A](thunk: => A): IO[A] = ???
implicit def applicativeForIO: Applicative[IO] = ???
}
trait Resource[+F[_], +A] {
def map[G[x] >: F[x], B](f: A => B)(implicit F: Applicative[G[*]]): Resource[G[*], B] = ???
}
object Resource {
def liftF[F[_], A](fa: F[A])(implicit F: Applicative[F]): Resource[F, A] = ???
}
object Test {
def test = for {
_ <- Resource.liftF(IO {})
} yield ()
} Compiled with current dotty master:
It compiles successfully after swapping It also compiles successfully with With regards to the original post, it seems like the majority of the errors are due to implicit search failures, and the remainder are fixed by #10205? |
I don't have a nice minimization for this one yet, but it appears that type lambdas change the meaning of the type in subtle ways. Consider this commit: typelevel/cats-effect@ef891ca Note the use of
G[*]
in place ofG
throughout many of the functions inResource
, such asallocated
. This is a workaround for a bug in Scala 2 (described here: typelevel/cats-effect#807). Unfortunately, it also seems to break Dotty entirely.With the
G[*]
construction in place, Dotty refuses to compile this commit, with most of the errors taking the form of trying to find anApplicative
for something like[A] ==>> IO[A]
. Swapping outG[*]
forG
fixes the issue, though it sets us back in terms of Scala 2 support, since we need to find a different workaround for the aforementioned bug.The text was updated successfully, but these errors were encountered: