Dotty Documentation

0.4.0-bin-SNAPSHOT

object desugar

[-] Constructors

[-] Members

[+] private object IdPattern

If tree is of the form id or id: T, return its name and type, otherwise return None.

[+] private class IrrefutableGenFrom
[+] class SetterParamTree
[+] class TypeRefTree
[+] private type VarInfo = ( NameTree, Tree )

Info of a variable in a pattern: The named tree and its type

[+] val AccessOrSynthetic : FlagSet
[+] val MaybeFilter : Key [ Unit ]

Tags a .withFilter call generated by desugaring a for expression. Such calls can alternatively be rewritten to use filter.

[+] @sharable private val synthetic : R
[+] private def addEvidenceParams ( meth: DefDef , params: List [ ValDef ] ) ( implicit ctx: Context ) : DefDef
[+] def apply ( tree: Tree ) ( implicit ctx: Context ) : Tree
[+] def block ( tree: Block ) ( implicit ctx: Context ) : Block

{ stats; } ==> { stats; () }

[+] def checkNotReservedName ( mdef: MemberDef ) ( implicit ctx: Context ) : Name

The name of mdef, after checking that it does not redefine a Scala core class. If it does redefine, issue an error and return a mangled name instead of the original one.

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

The expansion of a class definition. See inline comments for what is involved

[+] def defDef ( meth: DefDef , isPrimaryConstructor: Boolean ) ( implicit ctx: Context ) : Tree

Expand context bounds to evidence params. E.g.,

def f[T >: L <: H : B](params)

==> def fT >: L <: H(implicit evidence$0: B[T])

Expand default arguments to default getters. E.g,

def f[T: B](x: Int = 1)(y: String = x + "m") = ...

==> def f[T](x: Int)(y: String)(implicit evidence$0: B[T]) = ... def f$default$1[T] = 1 def f$default$2[T](x: Int) = x + "m"

[+] def defTree ( tree: Tree ) ( implicit ctx: Context ) : Tree
[+] private def derivedDefDef ( original: Tree , named: NameTree , tpt: Tree , rhs: Tree , mods: Modifiers ) : DefDef [ Untyped ]
[+] def derivedTermParam ( vdef: ValDef ) : ValDef

A value definition copied from vdef with a tpt typetree derived from it

[+] def derivedTypeParam ( tdef: TypeDef ) : TypeDef

A type definition copied from tdef with a rhs typetree derived from it

[+] private def derivedValDef ( original: Tree , named: NameTree , tpt: Tree , rhs: Tree , mods: Modifiers ) ( implicit ctx: Context ) : Tree
[+] private def evidenceParams ( meth: DefDef ) ( implicit ctx: Context ) : List [ ValDef ]

The implicit evidence parameters of meth, as generated by desugar.defDef

[+] private def getVariables ( tree: Tree ) ( implicit ctx: Context ) : List [ VarInfo ]

Returns list of all pattern variables, possibly with their types, without duplicates

[+] def isDesugaredCaseClassMethodName ( name: Name ) ( implicit ctx: Context ) : Boolean

Names of methods that are added unconditionally to case classes

[+] def makeAnnotated ( fullName: String , tree: Tree ) ( implicit ctx: Context ) : Annotated

Add annotation to tree: tree @fullName

The annotation is usually represented as a TypeTree referring to the class with the given name fullName. However, if the annotation matches a file name that is still to be entered, the annotation is represented as a cascade of Selects following fullName. This is necessary so that we avoid reading an annotation from the classpath that is also compiled from source.

[+] def makeCaseLambda ( cases: List [ CaseDef ] , nparams: Int , unchecked: Boolean ) ( implicit ctx: Context ) : R

If nparams == 1, expand partial function

 { cases }

==> x$1 => (x$1 @unchecked) match { cases }

If nparams != 1, expand instead to

 (x$1, ..., x$n) => (x$0, ..., x${n-1} @unchecked) match { cases }
[+] def makeClosure ( params: List [ ValDef ] , body: Tree , tpt: Tree , inlineable: Boolean ) ( implicit ctx: Context ) : Block

Make closure corresponding to function. params => body ==> def $anonfun(params) = body Closure($anonfun)

If inlineable is true, tag $anonfun with an @inline annotation.

[+] def makeImplicitFunction ( formals: List [ Type ] , body: Tree ) ( implicit ctx: Context ) : Tree
[+] def makeImplicitParameters ( tpts: List [ Tree ] , forPrimaryConstructor: Boolean ) ( implicit ctx: Context ) : List [ ValDef [ Untyped ] ]
[+] def makePatDef ( original: Tree , mods: Modifiers , pat: Tree , rhs: Tree ) ( implicit ctx: Context ) : Tree

If pat is a variable pattern,

val/var/lazy val p = e

Otherwise, in case there is exactly one variable x_1 in pattern val/var/lazy val p = e ==> val/var/lazy val x_1 = (e: @unchecked) match (case p => (x_1))

in case there are zero or more than one variables in pattern val/var/lazy p = e ==> private[this] synthetic [lazy] val t$ = (e: @unchecked) match (case p => (x_1, ..., x_N)) val/var/def x_1 = t$._1 ... val/var/def x_N = t$._N If the original pattern variable carries a type annotation, so does the corresponding ValDef or DefDef.

[+] def makeTupledFunction ( params: List [ ValDef ] , body: Tree ) ( implicit ctx: Context ) : Tree

Map n-ary function (p1, ..., pn) => body where n != 1 to unary function as follows:

x$1 => { def p1 = x$1._1 ... def pn = x$1._n body }

[+] def moduleDef ( mdef: ModuleDef ) ( implicit ctx: Context ) : Tree

Expand

object name extends parents { self => body }

to: val name: name$ = New(name$) final class name$ extends parents { self: name.type => body }

[+] def patDef ( pdef: PatDef ) ( implicit ctx: Context ) : Tree

val p1, ..., pN: T = E ==> makePatDef[[val p1: T1 = E]]; ...; makePatDef[[val pN: TN = E]]

case e1, ..., eN

==> expandSimpleEnumCase([case e1]); ...; expandSimpleEnumCase([case eN])

[+] def patternVar ( tree: Tree ) ( implicit ctx: Context ) : Bind

Expand variable identifier x to x @ _

[+] def refinedTypeToClass ( parent: Tree , refinements: List [ Tree ] ) ( implicit ctx: Context ) : TypeDef

Create a class definition with the same info as the refined type given by parent and refinements.

parent { refinements }

==> trait extends core { this: self => refinements }

Here, core is the (possibly parameterized) class part of parent. If parent is the same as core, self is empty. Otherwise self is parent.

Example: Given

class C
type T1 = C { type T <: A }

the refined type

T1 { type T <: B }

is expanded to

trait <refinement> extends C { this: T1 => type T <: A }

The result of this method is used for validity checking, is thrown away afterwards.

[+] private def toDefParam ( tparam: TypeDef ) : TypeDef
[+] private def toDefParam ( vparam: ValDef ) : ValDef
[+] def typeDef ( tdef: TypeDef ) ( implicit ctx: Context ) : Tree

Fill in empty type bounds with Nothing/Any. Expand private local type parameters as follows:

class C[v T] ==> class C { type v C$T; type v T = C$T }

[+] def valDef ( vdef: ValDef ) ( implicit ctx: Context ) : Tree

var x: Int = expr ==> def x: Int = expr def x_=($1: <TypeTree()>): Unit = ()