Dotty Documentation

0.9.0-bin-SNAPSHOT

class SuperAccessors
extends Object

This class adds super accessors for all super calls that either appear in a trait or have as a target a member of some outer class.

It also checks that:

(1) Symbols accessed from super are not abstract, or are overridden by an abstract override.

(2) If a symbol accessed from super is defined in a real class (not a trait), there are no abstract members which override this member in Java's rules (see SI-4989; such an access would lead to illegal bytecode)

(3) Super calls do not go to some synthetic members of Any (see isDisallowed)

(4) Super calls do not go to synthetic field accessors

[-] Constructors

SuperAccessors ( thisPhase: DenotTransformer )

[-] Members

[+] private val accDefs : MutableSymbolMap [ ListBuffer [ Tree ] ]

List buffers for new accessor definitions, indexed by class

[+] private var invalidEnclClass : Symbol

Some parts of trees will get a new owner in subsequent phases. These are value class methods, which will become extension methods. (By-name arguments used to be included also, but these don't get a new class anymore, they are just wrapped in a new method).

These regions will have to be treated specially for the purpose of adding accessors. For instance, super calls from these regions always have to go through an accessor.

The invalidEnclClass field, if different from NoSymbol, contains the symbol that is not a valid owner.

[+] private val thisPhase : DenotTransformer
[+] private def isDisallowed ( sym: Symbol ) ( implicit ctx: Context ) : Boolean

Disallow some super.XX calls targeting Any methods which would otherwise lead to either a compiler crash or runtime failure.

[+] private def superAccessorCall ( sel: Select ) ( implicit ctx: Context ) : Select

A super accessor call corresponding to sel

[+] def transformSelect ( tree: Tree , targs: List [ Tree ] ) ( implicit ctx: Context ) : Tree

Transform select node, adding super and protected accessors as needed

[+] private def transformSuperSelect ( sel: Select ) ( implicit ctx: Context ) : Tree

Check selection super.f for conforming to rules. If necessary, replace by a super accessor call.

[+] private def validCurrentClass ( implicit ctx: Context ) : Boolean
[+] private def withInvalidCurrentClass ( trans: => A ) ( implicit ctx: Context ) : A
[+] def wrapDefDef ( ddef: DefDef ) ( op: => DefDef ) ( implicit ctx: Context ) : DefDef

Wrap DefDef producing operation op, potentially setting invalidClass info

[+] def wrapTemplate ( tree: Template ) ( op: Template => Template ) ( implicit ctx: Context ) : Template

Wrap template to template transform op with needed initialization and finalization