Skip to content

Enum expansion does not work for singleton type parameters #3935

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
odersky opened this issue Jan 28, 2018 · 3 comments
Closed

Enum expansion does not work for singleton type parameters #3935

odersky opened this issue Jan 28, 2018 · 3 comments

Comments

@odersky
Copy link
Contributor

odersky commented Jan 28, 2018

The following produces a type error:

enum Foo3[T](x: T) {
  case Bar[S, T](y: T) extends Foo3[y.type](y)
}

See discussion in #3903 for details. The problem is that the expansion of Bar's apply method does not typecheck:

def apply[S, T](y: T): Foo3[y.type] = new Foo3.Bar[S, T](y)

A proper fix would require #3920 to be addressed. We could try to prevent code like this by restricting enum case parents, but maybe it's simpler to just accept that the expansion need not
always be type correct.

@smarter
Copy link
Member

smarter commented Jan 29, 2018

If we can convince ourselves that it won't lead to unsoundness, this could be solved by adding a cast:

def apply[S, T](y: T): Foo3[y.type] = (new Foo3.Bar[S, T](y)).asInstanceOf[Foo3[y.type]]

@bishabosha
Copy link
Member

this will be fixed when we have the precise .apply for companion of Bar

bishabosha added a commit to dotty-staging/dotty that referenced this issue Sep 4, 2020
bishabosha added a commit to dotty-staging/dotty that referenced this issue Sep 4, 2020
bishabosha added a commit to dotty-staging/dotty that referenced this issue Sep 4, 2020
bishabosha added a commit to dotty-staging/dotty that referenced this issue Sep 4, 2020
bishabosha added a commit to dotty-staging/dotty that referenced this issue Sep 29, 2020
bishabosha added a commit to dotty-staging/dotty that referenced this issue Sep 30, 2020
bishabosha added a commit to dotty-staging/dotty that referenced this issue Sep 30, 2020
bishabosha added a commit to dotty-staging/dotty that referenced this issue Sep 30, 2020
@bishabosha
Copy link
Member

fixed by #9932

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

Successfully merging a pull request may close this issue.

3 participants