Your code is almost right, just change the parameter of type Expr :
val expr = reify { ... } c.Expr[T](expr.tree)
Without reify you should return this:
c.Expr[T](Apply(Select(c.prefix.tree, newTermName("fullAdd")), List(param.tree, Literal(Constant(show(param.tree))))))
reify creates the same, but with the wrong type parameter.
See this answer for using showRaw .
In this case:
scala> import reflect.runtime.universe._ import reflect.runtime.universe._ scala> { | object Demo { def fullAdd(param1: Any, param2: String): String = "result" } | showRaw{ reify { Demo.fullAdd("param1", "param2") } } | } res0: String = Expr(Apply(Select(Ident(newTermName("Demo")), newTermName("fullAdd")), List(Literal(Constant("param1")), Literal(Constant("param2")))))
Replace Ident(newTermName("Demo")) with c.prefix.tree , Literal(Constant("param1")) with param.tree and "param2" with show(param.tree) and you will get your result.
senia source share