Skip to content

Enum expansion does not work for singleton type parameters #3935

Closed
@odersky

Description

@odersky

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions