Skip to content
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

can't existentially abstract over parameterized type F #9281

Open
scabug opened this issue Apr 24, 2015 · 1 comment
Open

can't existentially abstract over parameterized type F #9281

scabug opened this issue Apr 24, 2015 · 1 comment

Comments

@scabug
Copy link

scabug commented Apr 24, 2015

Consider the following snippet. Casting to existential causing the error "can't existentially abstract over parameterized type F".

test1 fails for both scala 2.10 and 2.11
test2 works for 2.10 but fails for 2.11
test3 works for 2.10 and 2.11

  // define container trait, type alias and value
  trait Container[F[_]]
  type CC[F[_]] = Container[F]
  val c = new CC[Option] {}

  // fails for 2.10 and 2.11
  // error: can't existentially abstract over parameterized type F
  type SomeContainer = Container[F] forSome { type F[_] }
  val test1 = c.asInstanceOf[SomeContainer]

  // works for 2.10 but fails for 2.11
  type SomeCC = CC[F] forSome { type F[_] }
  implicitly[SomeContainer =:= SomeCC]
  val test2 = c.asInstanceOf[SomeCC]

  // workaround for 2.11 but isn't it the same as test2?
  type SomeF[X] = F[X] forSome { type F[_] }
  implicitly[SomeCC =:= CC[SomeF]]
  val test3 = c.asInstanceOf[CC[SomeF]]

from my point of view test1 and test2 should work either

@scabug
Copy link
Author

scabug commented Apr 24, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9281?orig=1
Reporter: Dmitry Bushev (4e6)
Affected Versions: 2.10.5, 2.11.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants