diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-09-12 12:02:40 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-09-17 18:07:17 +0200 |
commit | 0c551f00f43c1675aca3adbff7567f47432c66f6 (patch) | |
tree | b5b770f7c221cf4110956713dd4855141f3493e1 | |
parent | c2402d232a7531778f71fc033da4d83bf7f06212 (diff) | |
download | dotty-0c551f00f43c1675aca3adbff7567f47432c66f6.tar.gz dotty-0c551f00f43c1675aca3adbff7567f47432c66f6.tar.bz2 dotty-0c551f00f43c1675aca3adbff7567f47432c66f6.zip |
More convinient appliedToNone
-rw-r--r-- | src/dotty/tools/dotc/ast/tpd.scala | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala index 7cb697c46..101631738 100644 --- a/src/dotty/tools/dotc/ast/tpd.scala +++ b/src/dotty/tools/dotc/ast/tpd.scala @@ -497,7 +497,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { Try(tree: Tree)(expr, handler, finalizer) } - implicit class TreeOps[ThisTree <: tpd.Tree](val tree: ThisTree) extends AnyVal { + implicit class TreeOps[ThisTree <: tpd.Tree](val tree: ThisTree)/* extends AnyVal*/ { def isValue(implicit ctx: Context): Boolean = tree.isTerm && tree.tpe.widen.isValueType @@ -554,7 +554,13 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { def appliedToArgss(argss: List[List[Tree]])(implicit ctx: Context): Tree = ((tree: Tree) /: argss)(Apply(_, _)) - def appliedToNone(implicit ctx: Context): Apply = appliedToArgs(Nil) + def appliedToNone(implicit ctx: Context): Tree = { + tree.tpe.widen match { + case fntpe: MethodType => appliedToArgs(Nil) + case _ => tree + } + } + def appliedToType(targ: Type)(implicit ctx: Context): Tree = appliedToTypes(targ :: Nil) |