Skip to content

Can't define an enum with higher kinded types #3976

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

Closed
halcat0x15a opened this issue Feb 8, 2018 · 2 comments
Closed

Can't define an enum with higher kinded types #3976

halcat0x15a opened this issue Feb 8, 2018 · 2 comments

Comments

@halcat0x15a
Copy link

I get an error in Dotty 0.6.0-RC1.

scala> enum class Hoge[F[_]]
1 |enum class Hoge[F[_]]
  |^
  |Type argument F$1 has not the same kind as its bound

I guessed that it failed to derive an Eq instance.

@halcat0x15a
Copy link
Author

I think that will be fixed if #3970 is implemented.

@smarter
Copy link
Member

smarter commented Feb 10, 2018

The error comes from an incorrectly generated implicit instance of Eq:

  final module class Hoge$() extends Object() { this: Hoge.type => 
    implicit def eqInstance[F$1 <: [_$1] => Any, F$2 <: [_$1] => Any](
      implicit evidence$1: Eq[F$1, F$2]
    ): Eq[Hoge[F$1], Hoge[F$2]] = Eq
  }

Eq[F$1, F$2] does not typecheck since F$1 and F$2 are type constructors. Maybe replacing this by Eq[F$1[_], F$2[_]] is good enough, not sure.

odersky added a commit that referenced this issue Feb 12, 2018
Fix #3976: Fix Eq method for enums with higher-kinded parameters
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