Skip to content

Problem extending java.lang.Enum #7174

@ekrich

Description

@ekrich

minimized code

import java.{lang => jl}

final class ConfigSyntax private (name: String, ordinal: Int)
    extends jl.Enum[ConfigSyntax](name, ordinal)

object ConfigSyntax {

  final val JSON = new ConfigSyntax("JSON", 0)
  final val CONF = new ConfigSyntax("CONF", 1)
  final val PROPERTIES = new ConfigSyntax("PROPERTIES", 2)

  private[this] final val _values: Array[ConfigSyntax] =
    Array(JSON, CONF, PROPERTIES)

  def values: Array[ConfigSyntax] = _values.clone()

  def valueOf(name: String): ConfigSyntax =
    _values.find(_.name == name).getOrElse {
      throw new IllegalArgumentException("No enum const ConfigSyntax." + name)
    }
}

problem

Currently the compiler requires an alias or fully specified class name for java.lang.Enum and errors when compiling.

too many arguments for constructor Enum: (): Enum[ConfigSyntax]

expectation

Should compile and not require a fully specified class name.

Metadata

Metadata

Labels

area:desugarDesugaring happens after parsing but before typing, see desugar.scalaarea:enumsitype:bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions