This phase performs the following transformations:
-
(done in
traitDefs
andtransformSym
) Map every concrete trait getterdef x(): T = expr
to the pair of definitions:
<mods> def x(): T
protected def initial$x(): T = { stats; expr }
where stats
comprises all statements between either the start of the trait
or the previous field definition which are not definitions (i.e. are executed for
their side effects).
-
(done in
traitDefs
) Make every concrete trait setterdef x_=(y: T) = ()
deferred by mapping it to
<mods> def x_=(y: T)
-
For a non-trait class C:
For every trait M directly implemented by the class (see SymUtils.mixin), in reverse linearization order, add the following definitions to C:
3.1 (done in `traitInits`) For every parameter accessor `<mods> def x(): T` in M, in order of textual occurrence, add <mods> def x() = e where `e` is the constructor argument in C that corresponds to `x`. Issue an error if no such argument exists. 3.2 (done in `traitInits`) For every concrete trait getter `<mods> def x(): T` in M which is not a parameter accessor, in order of textual occurrence, produce the following: 3.2.1 If `x` is also a member of `C`, and M is a Dotty trait: <mods> def x(): T = super[M].initial$x() 3.2.2 If `x` is also a member of `C`, and M is a Scala 2.x trait: <mods> def x(): T = _ 3.2.3 If `x` is not a member of `C`, and M is a Dotty trait: super[M].initial$x() 3.2.4 If `x` is not a member of `C`, and M is a Scala2.x trait, nothing gets added. 3.3 (done in `superCallOpt`) The call: super[M].<init> 3.4 (done in `setters`) For every concrete setter `<mods> def x_=(y: T)` in M: <mods> def x_=(y: T) = ()
-
(done in
transformTemplate
andtransformSym
) Drop all parameters from trait constructors. - (done in
transformSym
) Drop ParamAccessor flag from all parameter accessors in traits.
Conceptually, this is the second half of the previous mixin phase. It needs to run after erasure because it copies references to possibly private inner classes and objects into enclosing classes where they are not visible. This can only be done if all references are symbolic.
Constructors
Members
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:
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
List of names of phases that should precede this phase
List of names of phases that should precede this phase