Skip to content

Commit

Permalink
SI-6371 adds comments for Trees#UnApply
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
xeno-by committed Sep 14, 2012
1 parent dd7fa89 commit ed913c2
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/library/scala/reflect/base/Trees.scala
Expand Up @@ -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

Expand Down

0 comments on commit ed913c2

Please sign in to comment.