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
compile error scalaz with Scala 2.13.2 ( "covariant type A occurs in invariant position") #11953
Labels
Comments
@joroKr21 might this have to do with scala/scala#8545 ? |
more simpler example package example
sealed trait IList[A]
sealed abstract case class INil[A] () extends IList[A]
object INil {
private[this] final class _INil[+A] extends INil[A]
} |
This is unsound in general so scalac is right to reject this code: sealed trait IList[A]
sealed abstract case class INil[A]() extends IList[A] { var elem: A = _ }
object INil {
private[this] final class _INil[+A] extends INil[A]
def main(args: Array[String]): Unit = {
val n = new _INil[Int]
(n: _INil[Any]).elem = "foo"
val i: Int = n.elem // ClassCastException
}
} |
(you should be able to use |
Thank you for quick response! |
What @smarter said 😄 |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
reproduction steps
problem
expectation
not compile error.
The text was updated successfully, but these errors were encountered: