Skip to content

Enum case can't be defined in terms of itself #11443

@dwijnand

Description

@dwijnand

Compiler version

3.0.0-M3

Minimized code

enum Opt[T] {
  case Nn extends Opt[Nothing] with Comparable[Nn.type]

  def compareTo(nn: Nn.type) = 0
}

Output

2 |  case Nn extends Opt[Nothing] with Comparable[Nn.type]
  |                                               ^
  |                                             Recursive value Nn needs type

Expectation

I expected it to work much like the Scala 2 equivalent:

sealed trait Opt[T]
case object Nn extends Opt[Nothing] with Comparable[Nn.type] {
  def compareTo(nn: Nn.type) = 0
}

Btw, this error was also mentioned in #11249 but the original issue there is about vals.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions