Dotty Documentation

0.2.0-bin-SNAPSHOT

class LambdaLift
extends DotClass with MiniPhase with IdentityDenotTransformer

This phase performs the necessary rewritings to eliminate classes and methods nested in other methods. In detail: 1. It adds all free variables of local functions as additional parameters (proxies). 2. It rebinds references to free variables to the corresponding proxies, 3. It lifts all local functions and classes out as far as possible, but at least to the enclosing class. 4. It stores free variables of non-trait classes as additional fields of the class. The fields serve as proxies for methods in the class, which avoids the need of passing additional parameters to these methods.

A particularly tricky case are local traits. These cannot store free variables as field proxies, because LambdaLift runs after Mixin, so the fields cannot be expanded anymore. Instead, methods of local traits get free variables of the trait as additional proxy parameters. The difference between local classes and local traits is illustrated by the two rewritings below.

def f(x: Int) = { def f(x: Int) = new C(x).f2 class C { ==> class C(x$1: Int) { def f2 = x def f2 = x$1 } } new C().f2 }

def f(x: Int) = { def f(x: Int) = new C().f2(x) trait T { ==> trait T def f2 = x def f2(x$1: Int) = x$1 } } class C extends T class C extends T new C().f2 }

[-] Constructors

LambdaLift ( )

[-] Members

[+] class LambdaLifter
[+] val phaseName : String

the following two members override abstract members in Transform

[+] val treeTransform : TreeTransform
[+] override def relaxedTyping : Boolean

If set, allow missing or superfluous arguments in applications and type applications.

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

List of names of phases that should precede this phase