Skip to content

Commit 8a9efcc

Browse files
committed
Update internal documentation in Delambdafy phase
1 parent d12d59a commit 8a9efcc

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/compiler/scala/tools/nsc/transform/Delambdafy.scala

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,29 @@ import scala.reflect.internal.Symbols
99
import scala.collection.mutable.LinkedHashMap
1010

1111
/**
12-
* This transformer is responsible for turning lambdas into anonymous classes.
12+
* This transformer is responsible for preparing lambdas for runtime, by either translating to anonymous classes
13+
* or to a tree that will be convereted to invokedynamic by the JVM 1.8+ backend.
14+
*
1315
* The main assumption it makes is that a lambda {args => body} has been turned into
1416
* {args => liftedBody()} where lifted body is a top level method that implements the body of the lambda.
1517
* Currently Uncurry is responsible for that transformation.
1618
*
17-
* From a lambda, Delambdafy will create
19+
* From a lambda, Delambdafy will create:
20+
*
21+
* Under -target:jvm-1.7 and below:
22+
*
1823
* 1) a new top level class that
1924
a) has fields and a constructor taking the captured environment (including possibly the "this"
2025
* reference)
2126
* b) an apply method that calls the target method
2227
* c) if needed a bridge method for the apply method
2328
* 2) an instantiation of the newly created class which replaces the lambda
2429
*
25-
* TODO the main work left to be done is to plug into specialization. Primarily that means choosing a
26-
* specialized FunctionN trait instead of the generic FunctionN trait as a parent and creating the
27-
* appropriately named applysp method
30+
* Under -target:jvm-1.8 with GenBCode:
31+
*
32+
* 1) An application of the captured arguments to a fictional symbol representing the lambda factory.
33+
* This will be translated by the backed into an invokedynamic using a bootstrap method in JDK8's `LambdaMetaFactory`.
34+
* The captured arguments include `this` if `liftedBody` is unable to be made STATIC.
2835
*/
2936
abstract class Delambdafy extends Transform with TypingTransformers with ast.TreeDSL with TypeAdaptingTransformer {
3037
import global._

0 commit comments

Comments
 (0)