Dotty Documentation


class ExtensionMethods
extends MiniPhaseTransform with DenotTransformer with FullParameterization

Perform Step 1 in the inline classes SIP: Creates extension methods for all methods in a value class, except parameter or super accessors, or constructors.

Additionally, for a value class V, let U be the underlying type after erasure. We add to the companion module of V two cast methods: def u2evt$(x0: U): ErasedValueType(V, U) def evt2u$(x0: ErasedValueType(V, U)): U The casts are used in [[Erasure]] to make it typecheck, they are then removed in [[ElimErasedValueType]]. This is different from the implementation of value classes in Scala 2 (see SIP-15) which uses asInstanceOf which does not typecheck.

Finally, if the constructor of a value class is private pr protected it is widened to public.

[-] Constructors

ExtensionMethods ( )

[-] Members

[+] private val extensionDefs : Map [ Symbol, ListBuffer [ Tree ] ]
[+] override def changesMembers : Boolean

Can this transform create or delete non-private members?

[+] private def createExtensionMethod ( imeth: Symbol , staticClass: Symbol ) ( implicit ctx: Context ) : TermSymbol
[+] override def phaseName : String

the following two members override abstract members in Transform

[+] protected def rewiredTarget ( target: Symbol , derived: Symbol ) ( implicit ctx: Context ) : Symbol

If references to original symbol referenced from within fully parameterized method derived should be rewired to some fully parameterized method, the rewiring target symbol, otherwise NoSymbol.

[+] override def runsAfter : Set [ Class [ Nothing <: Phase ] ]

List of names of phases that should precede this phase

[+] override def runsAfterGroupsOf : Set [ Class [ Nothing <: Phase ] ]

List of names of phases that should have finished their processing of all compilation units before this phase starts

[+] override def transform ( ref: SingleDenotation ) ( implicit ctx: Context ) : SingleDenotation

The transformation method

[+] override def transformDefDef ( tree: DefDef ) ( implicit ctx: Context , info: TransformerInfo ) : Tree
[+] override def transformTemplate ( tree: Template ) ( implicit ctx: Context , info: TransformerInfo ) : Tree