Dotty Documentation

0.11.0-bin-SNAPSHOT

object DesugarEnums
extends Object

Helper methods to desugar enums

[-] Constructors

[-] Members

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

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

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

Add implied flags to an enum class or an enum case

[+] def enumApplyResult ( cdef: TypeDef , parents: List [ Tree ] , tparams: List [ TypeDef ] , appliedEnumRef: Tree ) ( implicit ctx: Context ) : ( Tree, List [ DefDef ] )

The return type of an enum case apply method and any widening methods in which the apply's right hand side will be wrapped. For parents of the form

extends E(args) with T1(args1) with ... TN(argsN)

and type parameters tparams the generated widen method is

def C$to$E[tparams](x$1: E[tparams] with T1 with ... TN) = x$1
[+] def enumClass ( implicit ctx: 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.

[+] def enumClassRef ( implicit ctx: Context ) : Tree

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.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

[+] 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 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

[+] def expandSimpleEnumCase ( name: TermName , mods: Modifiers , pos: Position ) ( implicit ctx: Context ) : Tree

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

Is tree an (untyped) enum case?

[+] def nextEnumTag ( kind: Value ) ( implicit ctx: Context ) : ( Int, List [ Tree ] )
[+] private def registerCall ( implicit ctx: Context ) : List [ Tree ]
[+] private def valuesDot ( name: String ) : Select