DesugarEnums

object DesugarEnums

Helper methods to desugar enums

class Object
trait Matchable
class Any

Type members

Classlikes

object CaseKind extends Enumeration
final case class EnumConstraints(minKind: Value, maxKind: Value, enumCases: List[(Int, RefTree)])

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

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.

A type tree referring to enumClass

A type tree referring to enumClass

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

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

Expand a simple enum case

Expand a simple enum case

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.

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

Is tree an (untyped) enum case?

Is tree an (untyped) enum case?

def nextOrdinal(name: Name, kind: Value, 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.
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

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.

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.