From 5d29697365245707af1a037678a7b48b0fef341c Mon Sep 17 00:00:00 2001 From: James Iry Date: Wed, 28 Aug 2013 20:41:12 -0700 Subject: Flesh out the Delambdafy phase. This commit puts a real body on the Delambdafy phase. From a lambda, Delambdafy will create 1) a static forwarder at the top level of the class that contained the lambda 2) a new top level class that a) has fields and a constructor taking the captured environment (including possbily the "this" reference) b) an apply method that calls the static forwarder c) if needed a bridge method for the apply method 3) an instantiation of the newly created class which replaces the lambda Trees.scala is modified to add two more convenient factories for templates and classdefs. A few basic tests are included to verify that it works as expected. Further commits will have additional tests. --- test/files/pos/delambdafy-lambdalift.scala | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 test/files/pos/delambdafy-lambdalift.scala (limited to 'test/files/pos/delambdafy-lambdalift.scala') diff --git a/test/files/pos/delambdafy-lambdalift.scala b/test/files/pos/delambdafy-lambdalift.scala new file mode 100644 index 0000000000..e9da24ef37 --- /dev/null +++ b/test/files/pos/delambdafy-lambdalift.scala @@ -0,0 +1,8 @@ +class LambdaLift { + + def enclosingMethod(capturedArg: Int): Unit = { + def innerMethod(x: Int): Int = x + capturedArg + val f = (y: Int) => innerMethod(y) + } + +} -- cgit v1.2.3