Dotty Documentation

0.1.1-bin-SNAPSHOT

class Mixin
extends MiniPhaseTransform with SymTransformer

This phase performs the following transformations:

  1. (done in traitDefs and transformSym) Map every concrete trait getter

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

  1. (done in traitDefs) Make every concrete trait setter

    def x_=(y: T) = ()

deferred by mapping it to

<mods> def x_=(y: T)
  1. 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) = ()
    
  2. (done in transformTemplate and transformSym) Drop all parameters from trait constructors.

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

Mixin ( )

[-] Members

[+] private def initializer ( sym: Symbol ) ( implicit ctx: Context ) : TermSymbol
[+] 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 runsAfter : Set [ Class [ Nothing <: Phase ] ]

List of names of phases that should precede this phase

[+] override def transformSym ( sym: SymDenotation ) ( implicit ctx: Context ) : SymDenotation
[+] override def transformTemplate ( impl: Template ) ( implicit ctx: Context , info: TransformerInfo ) : Tree