File tree Expand file tree Collapse file tree 1 file changed +4
-15
lines changed
src/main/scala-2/com/github/dwickern/macros Expand file tree Collapse file tree 1 file changed +4
-15
lines changed Original file line number Diff line number Diff line change @@ -50,32 +50,21 @@ object NameOfImpl {
5050 def qualifiedNameOf (c : whitebox.Context )(expr : c.Expr [Any ]): c.Expr [String ] = {
5151 import c .universe ._
5252
53- def extractNames (tree : c.Tree ): List [c.Name ] = {
54- tree.children.headOption match {
55- case Some (child) =>
56- extractNames(child) :+ tree.symbol.name
57- case None =>
58- List (tree.symbol.name)
59- }
60- }
61-
62- @ tailrec def extract (tree : c.Tree ): List [c.Name ] = tree match {
53+ def extract (tree : c.Tree ): List [c.Name ] = tree match {
6354 case Ident (n) => List (n)
64- case Select (tree, n) => extractNames (tree) :+ n
55+ case Select (tree, n) => extract (tree) :+ n
6556 case Function (_, body) => extract(body)
6657 case Block (_, expr) => extract(expr)
6758 case Apply (func, _) => extract(func)
6859 case TypeApply (func, _) => extract(func)
69- case _ => c.abort(c.enclosingPosition, s " Unsupported expression: $expr" )
60+ case _ => c.abort(c.enclosingPosition, s " Unsupported expression: ${ expr.tree} } " )
7061 }
7162
7263 val name = extract(expr.tree)
7364 // drop sth like x$1
7465 .drop(1 )
7566 .mkString(" ." )
76- reify {
77- c.Expr [String ] { Literal (Constant (name)) }.splice
78- }
67+ c.Expr [String ](q " $name" )
7968 }
8069
8170 def nameOfType [T ](c : whitebox.Context )(implicit tag : c.WeakTypeTag [T ]): c.Expr [String ] = {
You can’t perform that action at this time.
0 commit comments