title: scala proxy macro, issue converting method args to values
body: <p>I am trying to write a proxy macro using scala macros. I want to be able to proxy a trait X and return instances of X that invoke a function for all methods of X.</p>
  
  <p>Here is what I did so far. Say we want to proxy the trait TheTrait (which is defined below), we can run ProxyMacro.proxy passing a function that will be called for all invocations of the proxy methods.</p>
  
  <pre><code>    trait TheTrait
      {
          def myMethod(x: String)(y: Int): String
      }
  
      val proxy = ProxyMacro.proxy[TheTrait] {
          case ("myMethod", args) =&gt;
              "ok"
      }
      println(proxy.myMethod("hello")(5))
  </code></pre>
  
  <p>The implementation so far is this:</p>
  
  <pre><code>package macrotests
  
  import scala.language.experimental.macros
  import scala.reflect.macros.whitebox.Context
  
  object ProxyMacro
  {
  type Implementor = (String, Any) =&gt; Any
  
  def proxy[T](implementor: Implementor): T = macro impl[T]
  
  def impl[T: c.WeakTypeTag](c: Context)(implementor: c.Expr[Implementor]): c.Expr[T] = {
      import c.universe._
  
      val tpe = weakTypeOf[T]
  
      val decls = tpe.decls.map { decl =&gt;
          val termName = decl.name.toTermName
          val method = decl.asMethod
          val params = method.paramLists.map(_.map(s =&gt; internal.valDef(s)))
          val paramVars = method.paramLists.flatMap(_.map { s =&gt;
              internal.captureVariable(s)
              internal.referenceCapturedVariable(s)
          })
  
          q""" def $termName (...$params) = {
              $implementor (${termName.toString}, List(..${paramVars}) ).asInstanceOf[${method.returnType}]
             }"""
      }
  
      c.Expr[T] {
          q"""
        new $tpe {
          ..$decls
        }
    """
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>But there is a problem. This doesn't compile due to List(..${paramVars}). This should just create a list with all the values of the method arguments.
  But I get a compilation issue (not worth pasting it) on that line.</p>
  
  <p>How can I convert the list of method arguments to their values?</p>