aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-12-03 19:32:09 +0100
committerMartin Odersky <odersky@gmail.com>2016-12-17 18:34:27 +0100
commit4fb19e43f696845a18cbe2a7671654674ffce9b7 (patch)
treeeaa6abbcaf7966041f2e10f1d7840d4f4ca1c6a9 /compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
parentad7edc7bd8af963b768afdc50b7038a8daa47ccb (diff)
downloaddotty-4fb19e43f696845a18cbe2a7671654674ffce9b7.tar.gz
dotty-4fb19e43f696845a18cbe2a7671654674ffce9b7.tar.bz2
dotty-4fb19e43f696845a18cbe2a7671654674ffce9b7.zip
Refactor function operations in Definitions
Also: show implicit function types correctly. Also: refine applications of implicit funcitons - don't do it for closure trees - don't do it after typer.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/ast/TreeInfo.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/ast/TreeInfo.scala4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
index d1e6bd38a..ae7c93784 100644
--- a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
+++ b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
@@ -501,12 +501,14 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
*/
object closure {
def unapply(tree: Tree): Option[(List[Tree], Tree, Tree)] = tree match {
- case Block(_, Closure(env, meth, tpt)) => Some(env, meth, tpt)
+ case Block(_, expr) => unapply(expr)
case Closure(env, meth, tpt) => Some(env, meth, tpt)
case _ => None
}
}
+ def isClosure(tree: Tree) = closure.unapply(tree).isDefined
+
/** If tree is a closure, its body, otherwise tree itself */
def closureBody(tree: Tree)(implicit ctx: Context): Tree = tree match {
case Block((meth @ DefDef(nme.ANON_FUN, _, _, _, _)) :: Nil, Closure(_, _, _)) => meth.rhs