summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-09-14 14:39:34 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-09-15 00:55:17 +0200
commited913c2963c472440b06a3a4cfa3d2853cea21d4 (patch)
tree0c897c85310c0013b13bf39646d7e7875f8fd8f6 /src/library
parentdd7fa899035f77f2c4c3c136e681d87bf43bd1f3 (diff)
downloadscala-ed913c2963c472440b06a3a4cfa3d2853cea21d4.tar.gz
scala-ed913c2963c472440b06a3a4cfa3d2853cea21d4.tar.bz2
scala-ed913c2963c472440b06a3a4cfa3d2853cea21d4.zip
SI-6371 adds comments for Trees#UnApply
Unfortunately we cannot remove this node, because it's emitted by typer and, therefore, can be seen by macros and pickled as a part of annotations. Therefore we have to expose UnApply in the API. Experimental status of scala-reflect.jar will give us some leeway to evict it from the compiler (and consequently from the API) by 2.10.1.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/reflect/base/Trees.scala26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/library/scala/reflect/base/Trees.scala b/src/library/scala/reflect/base/Trees.scala
index 74928a0cc6..78174f354c 100644
--- a/src/library/scala/reflect/base/Trees.scala
+++ b/src/library/scala/reflect/base/Trees.scala
@@ -605,10 +605,30 @@ trait Trees { self: Universe =>
def unapply(bind: Bind): Option[(Name, Tree)]
}
- /** Noone knows what this is.
- * It is not idempotent w.r.t typechecking.
- * Can we, please, remove it?
+ /** Used to represent `unapply` methods in pattern matching.
* Introduced by typer, eliminated by patmat/explicitouter.
+ *
+ * For example:
+ * {{{
+ * 2 match { case Foo(x) => x }
+ * }}}
+ *
+ * Is represented as:
+ * {{{
+ * Match(
+ * Literal(Constant(2)),
+ * List(
+ * CaseDef(
+ * UnApply(
+ * // a dummy node that carries the type of unapplication to patmat
+ * // the <unapply-selector> here doesn't have an underlying symbol
+ * // it only has a type assigned, therefore after `resetAllAttrs` this tree is no longer typeable
+ * Apply(Select(Ident(Foo), newTermName("unapply")), List(Ident(newTermName("<unapply-selector>")))),
+ * // arguments of the unapply => nothing synthetic here
+ * List(Bind(newTermName("x"), Ident(nme.WILDCARD)))),
+ * EmptyTree,
+ * Ident(newTermName("x")))))
+ * }}}
*/
type UnApply >: Null <: TermTree