This phase adds outer accessors to classes and traits that need them. Compared to Scala 2.x, it tries to minimize the set of classes that take outer accessors by scanning class implementations for outer references.
The following things are delayed until erasure and are performed by class OuterOps:
- add outer parameters to constructors
- pass outer arguments in constructor calls
replacement of outer this by outer paths is done in Erasure. needs to run after pattern matcher as it can add outer checks and force creation of $outer
Denotations with a symbol where
mayChange is false are guaranteed to be
unaffected by this transform, so
transformInfo need not be run. This
can save time, and more importantly, can help avoid forcing symbol completers.
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 have finished their processing of all compilation units before this phase starts
Add outer accessors if a class always needs an outer pointer
Convert a selection of the form
qual.C_<OUTER> to an outer path from
First, add outer accessors if a class does not have them yet and it references an outer this. If the class has outer accessors, implement them. Furthermore, if a parent trait might have an outer accessor, provide an implementation for the outer accessor by computing the parent's outer from the parent type prefix. If the trait ends up not having an outer accessor after all, the implementation is redundant, but does not harm. The same logic is not done for non-trait parent classes because for them the outer pointer is passed in the super constructor, which will be implemented later in a separate phase which needs to run after erasure. However, we make sure here that the super class constructor is indeed a New, and not just a type.