DesugarEnums

dotty.tools.dotc.ast.DesugarEnums
object DesugarEnums

Helper methods to desugar enums

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

enum CaseKind

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class EnumConstraints(minKind: CaseKind, maxKind: CaseKind, enumCases: List[(Int, RefTree)])

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

def addEnumFlags(cdef: TypeDef)(using Context): TypeDef

Add implied flags to an enum class or an enum case

Add implied flags to an enum class or an enum case

Attributes

def enumClass(using Context): Symbol

The enumeration class that belongs to an enum case. This works no matter whether the case is still in the enum class or it has been transferred to the companion object.

The enumeration class that belongs to an enum case. This works no matter whether the case is still in the enum class or it has been transferred to the companion object.

Attributes

def enumClassRef(using Context): Tree

A type tree referring to enumClass

A type tree referring to enumClass

Attributes

def expandEnumModule(name: TermName, impl: Template, mods: Modifiers, definesLookups: Boolean, span: Span)(using Context): Tree

Expand a module definition representing a parameterless enum case

Expand a module definition representing a parameterless enum case

Attributes

def expandSimpleEnumCase(name: TermName, mods: Modifiers, definesLookups: Boolean, span: Span)(using Context): Tree

Expand a simple enum case

Expand a simple enum case

Attributes

def fromOrdinalMeth(body: Tree => Tree)(using Context): DefDef

A reference to the enum class E, possibly followed by type arguments. Each covariant type parameter is approximated by its lower bound. Each contravariant type parameter is approximated by its upper bound. It is an error if a type parameter is non-variant, or if its approximation refers to pther type parameters.

A reference to the enum class E, possibly followed by type arguments. Each covariant type parameter is approximated by its lower bound. Each contravariant type parameter is approximated by its upper bound. It is an error if a type parameter is non-variant, or if its approximation refers to pther type parameters.

Attributes

def isEnumCase(tree: Tree)(using Context): Boolean

Is tree an (untyped) enum case?

Is tree an (untyped) enum case?

Attributes

def nextOrdinal(name: Name, kind: CaseKind, definesLookups: Boolean)(using Context): (Int, List[Tree])

A pair consisting of

A pair consisting of

  • the next enum tag
  • scaffolding containing the necessary definitions for singleton enum cases unless that scaffolding was already generated by a previous call to nextEnumKind.

Attributes

def ordinalMeth(body: Tree)(using Context): DefDef
def ordinalMethLit(ord: Int)(using Context): DefDef
def param(name: TermName, typ: Type)(using Context): ValDef
def param(name: TermName, tpt: Tree)(using Context): ValDef
def typeParamIsReferenced(enumTypeParams: List[TypeSymbol], caseTypeParams: List[TypeDef], vparamss: List[List[ValDef]], parents: List[Tree])(using Context): Boolean

Is a type parameter in enumTypeParams referenced from an enum class case that has given type parameters caseTypeParams, value parameters vparamss and parents parents? Issues an error if that is the case but the reference is illegal. The reference could be illegal for two reasons:

Is a type parameter in enumTypeParams referenced from an enum class case that has given type parameters caseTypeParams, value parameters vparamss and parents parents? Issues an error if that is the case but the reference is illegal. The reference could be illegal for two reasons:

  • explicit type parameters are given
  • it's a value case, i.e. no value parameters are given

Attributes

Concrete fields

Attachment signalling that when this definition is desugared, it should add any additional lookup methods for enums.

Attachment signalling that when this definition is desugared, it should add any additional lookup methods for enums.

Attributes

Attachment containing the number of enum cases, the smallest kind that was seen so far, and a list of all the value cases with their ordinals.

Attachment containing the number of enum cases, the smallest kind that was seen so far, and a list of all the value cases with their ordinals.

Attributes