@@ -9,22 +9,29 @@ import scala.reflect.internal.Symbols
9
9
import scala .collection .mutable .LinkedHashMap
10
10
11
11
/**
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
+ *
13
15
* The main assumption it makes is that a lambda {args => body} has been turned into
14
16
* {args => liftedBody()} where lifted body is a top level method that implements the body of the lambda.
15
17
* Currently Uncurry is responsible for that transformation.
16
18
*
17
- * From a lambda, Delambdafy will create
19
+ * From a lambda, Delambdafy will create:
20
+ *
21
+ * Under -target:jvm-1.7 and below:
22
+ *
18
23
* 1) a new top level class that
19
24
a) has fields and a constructor taking the captured environment (including possibly the "this"
20
25
* reference)
21
26
* b) an apply method that calls the target method
22
27
* c) if needed a bridge method for the apply method
23
28
* 2) an instantiation of the newly created class which replaces the lambda
24
29
*
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.
28
35
*/
29
36
abstract class Delambdafy extends Transform with TypingTransformers with ast.TreeDSL with TypeAdaptingTransformer {
30
37
import global ._
0 commit comments