summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/internal/TreeInfo.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-08-15 15:02:19 -0700
committerPaul Phillips <paulp@improving.org>2013-08-17 08:22:52 -0700
commite76507f8793cd025b56ba2a0c3b0cc112bcc8aea (patch)
tree9353e27f0d01b2cda310da36ab666a9dc7a72d2b /src/reflect/scala/reflect/internal/TreeInfo.scala
parent35122d6cda84bb2df69ca51c6b1b80e61693bf6f (diff)
downloadscala-e76507f8793cd025b56ba2a0c3b0cc112bcc8aea.tar.gz
scala-e76507f8793cd025b56ba2a0c3b0cc112bcc8aea.tar.bz2
scala-e76507f8793cd025b56ba2a0c3b0cc112bcc8aea.zip
An Unapplied extractor.
This makes it a lot less error prone and redundant to find the part you need when unwrapping an UnApply tree.
Diffstat (limited to 'src/reflect/scala/reflect/internal/TreeInfo.scala')
-rw-r--r--src/reflect/scala/reflect/internal/TreeInfo.scala11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala
index d01f1ce681..34fe0afb1a 100644
--- a/src/reflect/scala/reflect/internal/TreeInfo.scala
+++ b/src/reflect/scala/reflect/internal/TreeInfo.scala
@@ -773,6 +773,17 @@ abstract class TreeInfo {
unapply(dissectApplied(tree))
}
+ /** Locates the synthetic Apply node corresponding to an extractor's call to
+ * unapply (unwrapping nested Applies) and returns the fun part of that Apply.
+ */
+ object Unapplied {
+ def unapply(tree: Tree): Option[Tree] = tree match {
+ case Apply(fun, Ident(nme.SELECTOR_DUMMY) :: Nil) => Some(fun)
+ case Apply(fun, _) => unapply(fun)
+ case _ => None
+ }
+ }
+
/** Is this file the body of a compilation unit which should not
* have Predef imported? This is the case iff the first import in the
* unit explicitly refers to Predef.