final object DesugarEnums

Helper methods to desugar enums

Constructors

Members

@sharable final object CaseKind
val EnumCaseCount : Key [ ( Int, Value ) ]

Attachment containing the number of enum cases and the smallest kind that was seen so far.

Attachment containing the number of enum cases and the smallest kind that was seen so far.

def addEnumFlags ( cdef: TypeDef ) ( implicit ctx: Context ) : TypeDef [ Untyped ]

Add implied flags to an enum class or an enum case

Add implied flags to an enum class or an enum case

def enumCaseIsLegal ( tree: Tree ) ( implicit ctx: Context ) : Boolean

Is enum case tree situated in a companion object of an enum class?

Is enum case tree situated in a companion object of an enum class?

def enumClass ( implicit ctx: Context ) : Symbol

the enumeration class that is a companion of the current object

the enumeration class that is a companion of the current object

def enumClassRef ( implicit ctx: Context ) : TypedSplice

A type tree referring to enumClass

A type tree referring to enumClass

[+] private def enumScaffolding ( implicit ctx: Context ) : List [ Tree ]

The following lists of definitions for an enum type E:

private val $values = new EnumValues[E] def enumValue = $values.fromInt def enumValueNamed = $values...

The following lists of definitions for an enum type E:

private val $values = new EnumValues[E] def enumValue = $values.fromInt def enumValueNamed = $values.fromName def enumValues = $values.values

def enumTagMeth ( kind: Value ) ( implicit ctx: Context ) : ( DefDef, List [ Tree ] )

A pair consisting of - a method returning the next enum tag - scaffolding as defined in nextEnumTag

A pair consisting of - a method returning the next enum tag - scaffolding as defined in nextEnumTag

[+] private def enumValueCreator ( implicit ctx: Context ) : DefDef

A creation method for a value of enum type E, which is defined as follows:

private def $new(tag: Int, name: String) = new E { def enumTag = tag override...

A creation method for a value of enum type E, which is defined as follows:

private def $new(tag: Int, name: String) = new E { def enumTag = tag override def toString = name $values.register(this) }

def expandEnumModule ( name: TermName , impl: Template , mods: Modifiers , pos: Position ) ( implicit ctx: 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 , pos: Position ) ( implicit ctx: Context ) : Tree

Expand a simple enum case

Expand a simple enum case

[+] def interpolatedEnumParent ( pos: Position ) ( implicit ctx: Context ) : Tree

A reference to the enum class E, possibly followed by type arguments. Each covariant type parameter is approximated by its lower bound. Each contravaria...

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 isLegalEnumCase ( tree: MemberDef ) ( implicit ctx: Context ) : Boolean

Is this an enum case that's situated in a companion object of an enum class?

Is this an enum case that's situated in a companion object of an enum class?

[+] def nextEnumTag ( kind: Value ) ( implicit ctx: Context ) : ( Int, List [ Tree ] )

A pair consisting of - the next enum tag - scaffolding containing the necessary definitions for singleton enum cases unless that scaffolding was already...

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 reconstitutedEnumTypeParams ( pos: Position ) ( implicit ctx: Context ) : List [ TypeDef [ Untyped ] ]

Type parameters reconstituted from the constructor of the `enum' class corresponding to an enum case. The variance is the same as the corresponding type...

Type parameters reconstituted from the constructor of the `enum' class corresponding to an enum case. The variance is the same as the corresponding type parameter of the enum class.

private def registerCall ( implicit ctx: Context ) : List [ Tree ]
private def valuesDot ( name: String ) : Select