bug icon indicating copy to clipboard operation
bug copied to clipboard

can't existentially abstract over parameterized type F

Open scabug opened this issue 10 years ago • 1 comments
trafficstars

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 avatar Apr 24 '15 10:04 scabug

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

scabug avatar Apr 24 '15 10:04 scabug