Dotty Documentation


class VCInlineMethods

This phase inlines calls to methods of value classes.

A value class V after [[ExtensionMethods]] will look like: class V[A, B, ...](val underlying: U) extends AnyVal { def foo[T, S, ...](arg1: A1, arg2: A2, ...) =$extensionT, S, ..., A, B, ...(arg1, arg2, ...)



Let e have type V, if e is a stable prefix or if V does not have any class type parameter, then we can rewrite: e.fooX, Y, ... as:$extensionX, Y, ..., A', B', ...(args) where A', B', ... are the class type parameters A, B, ... as seen from e. Otherwise, we need to evaluate e first: { val ev = e$extensionX, Y, ..., A', B', ...(args) }

This phase needs to be placed after phases which may introduce calls to value class methods (like [[PatternMatcher]]). This phase uses name mangling to find the correct extension method corresponding to a value class method (see [[ExtensionMethods.extensionMethod]]), therefore we choose to place it before phases which may perform their own name mangling on value class methods (like [[TypeSpecializer]]), this way [[VCInlineMethods]] does not need to have any knowledge of the name mangling done by other phases.

[-] Constructors

VCInlineMethods ( )

[-] Members

[+] 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
[+] private def rewire ( tree: Tree , mtArgs: List [ Tree ] , mArgss: List [ List [ Tree ] ] ) ( implicit ctx: Context ) : Tree

Replace a value class method call by a call to the corresponding extension method.

[+] private def rewireIfNeeded ( tree: Tree ) ( implicit ctx: Context ) : Tree

If this tree corresponds to a fully-applied value class method call, replace it by a call to the corresponding extension method, otherwise return it as is.

[+] override def runsAfter : Set [ String ]

List of names of phases that should precede this phase

[+] override def transformApply ( tree: Apply ) ( implicit ctx: Context ) : Tree
[+] override def transformSelect ( tree: Select ) ( implicit ctx: Context ) : Tree
[+] override def transformTypeApply ( tree: TypeApply ) ( implicit ctx: Context ) : Tree