-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Unsoundness with the variance of type lambda bounded type variables #9061
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 think we intentionally chose to not support this as one can always write |
@smarter |
We added class Foo { type X <: AnyKind }
class Bar extends Foo { type X[+A] <: String } |
case class Covarify[+F[_], +A](fa: F[A])
case class PolyK[K <: AnyKind, C[f[_ <: K], a <: K], F[_ <: K] , A <: K](c: C[F, A])
PolyK[ ??? , Covarify, List, Int](Covarify(List(1))) |
Not sure what's going on here, but you have |
@Odomontois The issue in that snippet seems to be not with AnyKind, but with variance on case class Covarify[+F[+_], +A](fa: F[A])
case class PolyK[K <: AnyKind, C[f[+_ <: K], a <: K], F[+_ <: K] , A <: K](c: C[F, A])
case class MonoK[C[f[+_], a], F[+_], A](c: C[F, A])
@main def main = {
MonoK[Covarify, List, Int](Covarify(List(1)))
PolyK[Any, Covarify, List, Int](Covarify(List(1)))
} |
Fix #9061: Treat `type F <: [X] => G` like `type F[X] <: G`.
Revert "Fix #9061: Treat `type F <: [X] => G` like `type F[X] <: G`."
(reopening because the fix had to be reverted, see #9086) |
It did not work for curried type lambdas.
Fix variance fixing code in the fix of #9061
Minimized code
https://scastie.scala-lang.org/ZfaseMB6QnyGTFsihR9FUQ
Output
Expectation
Either
case class Covarify[+F <: ([A] =>> Any), +A](fa: F[A])
orCovarify[Contra, Int]
should be rejected. Rejecting the former might require reintroducing type lambda variance, to be able to express the desired kindF[+_]
as the bound_ <: ([+A] =>> Any)
.The text was updated successfully, but these errors were encountered: