Skip to content

Instantly share code, notes, and snippets.

@milessabin
Created March 22, 2013 15:19
Show Gist options
  • Save milessabin/5222090 to your computer and use it in GitHub Desktop.
Save milessabin/5222090 to your computer and use it in GitHub Desktop.
Scala 2.9.x bug
// With -Ydependent-method-types
// Compiles with 2.10.x
scala> trait Algebra[F[_]] { trait Expr[A] }
defined trait Algebra
scala> trait ClosedExpr { def apply[F[_], A](algebra: Algebra[F]): algebra.Expr[A] }
defined trait ClosedExpr
scala> new ClosedExpr { def apply[F[_], A](algebra: Algebra[F]): algebra.Expr[A] = new algebra.Expr[A] {} }
<console>:10: error: can't existentially abstract over parameterized type F
new ClosedExpr { def apply[F[_], A](algebra: Algebra[F]): algebra.Expr[A] = new algebra.Expr[A] {} }
^
scala> class Foo extends ClosedExpr { def apply[F[_], A](algebra: Algebra[F]): algebra.Expr[A] = new algebra.Expr[A] {} }
<console>:9: error: overriding method apply in trait ClosedExpr of type [F[_], A](algebra: Algebra[F])algebra.Expr[A];
method apply has incompatible type
class Foo extends ClosedExpr { def apply[F[_], A](algebra: Algebra[F]): algebra.Expr[A] = new algebra.Expr[A] {} }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment