Dotty Documentation


class Getters
extends MiniPhase with SymTransformer

Performs the following rewritings for fields of a class:

val x: T = e --> def x: T = e var x: T = e --> def x: T = e

val x: T --> def x: T

lazy val x: T = e --> lazy def x: T =e

var x: T --> def x: T

non-static val x$ = e --> def x$ = e

Omitted from the rewritings are

  • private[this] fields in classes (excluding traits, value classes)
  • fields generated for static modules (TODO: needed?)
  • parameters, static fields, and fields coming from Java

Furthermore, assignments to mutable vars are replaced by setter calls

p.x = e --> p.x_=(e)

No fields are generated yet. This is done later in phase Memoize.

Also, drop the Local flag from all private[this] and protected[this] members. This allows subsequent code motions in Flatten.

[-] Constructors

Getters ( )

[-] Members

[+] private val NoGetterNeeded : FlagSet
[+] override def phaseName : String

A name given to the Phase that can be used to debug the compiler. For instance, it is possible to print trees after a given phase using:

$ ./bin/dotc -Xprint:<phaseNameHere> sourceFile.scala
[+] override def transformAssign ( tree: Assign ) ( implicit ctx: Context ) : Tree
[+] override def transformSym ( d: SymDenotation ) ( implicit ctx: Context ) : SymDenotation
[+] override def transformValDef ( tree: ValDef ) ( implicit ctx: Context ) : Tree