summaryrefslogtreecommitdiff
path: root/test/files/pos/delambdafy-patterns.scala
diff options
context:
space:
mode:
authorJames Iry <james.iry@typesafe.com>2013-08-28 20:41:12 -0700
committerJames Iry <james.iry@typesafe.com>2013-11-06 12:28:19 -0800
commit5d29697365245707af1a037678a7b48b0fef341c (patch)
treee21103cae9992c26774c61cd1e8ebc8b1381435f /test/files/pos/delambdafy-patterns.scala
parent510b8cecc4951ff8092cfa931c2dc3717e21dded (diff)
downloadscala-5d29697365245707af1a037678a7b48b0fef341c.tar.gz
scala-5d29697365245707af1a037678a7b48b0fef341c.tar.bz2
scala-5d29697365245707af1a037678a7b48b0fef341c.zip
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.
Diffstat (limited to 'test/files/pos/delambdafy-patterns.scala')
-rw-r--r--test/files/pos/delambdafy-patterns.scala15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/files/pos/delambdafy-patterns.scala b/test/files/pos/delambdafy-patterns.scala
new file mode 100644
index 0000000000..95d498629b
--- /dev/null
+++ b/test/files/pos/delambdafy-patterns.scala
@@ -0,0 +1,15 @@
+class DelambdafyPatterns {
+ def bar: Unit = ()
+ def wildcardPatternInTryCatch: Unit => Unit = (x: Unit) =>
+ // patterns in try..catch are preserved so we need to be
+ // careful when it comes to free variable detction
+ // in particular a is _not_ free variable, also the
+ // `_` identifier has no symbol attached to it
+ try bar catch {
+ case a@(_:java.lang.reflect.InvocationTargetException) =>
+ // refer to a so we trigger a bug where a is considered
+ // to be a free variable for enclosing lambda
+ val b = a
+ ()
+ }
+}