title: Scala reflection AST syntax
body: <p>I'm attempting to manually-generate ASTs using the reflection API, using showRaw to give me some hints on the required syntax. This code:</p>
  
  <pre><code>object myfn extends Function2[ Double, Double, Double ] {
      def apply( x : Double, y : Double ) = x + y
  }
  
  val x = 0.0
  println( showRaw( reify( myfn( x, x ) ).tree ) )
  </code></pre>
  
  <p>gives the raw AST output: </p>
  
  <pre><code>Apply(Select(Ident(myfn), newTermName("apply")), 
      List(Ident(newTermName("x")), Ident(newTermName("x"))))
  </code></pre>
  
  <p>Putting the literal text of the raw output back into the program won't compile:</p>
  
  <pre><code>val v = Apply(Select(Ident(myfn), newTermName("apply")), 
      List(Ident(newTermName("x")), Ident(newTermName("x"))))
  // ^ doesn't compile
  </code></pre>
  
  <p>since Ident apparently requires a String as an argument.
  If I pass in the string "myfn", then </p>
  
  <pre><code>val v = Apply(Select(Ident("myfn"), newTermName("apply")), 
      List(Ident(newTermName("x")), Ident(newTermName("x"))))
  
  runtimeMirror( getClass.getClassLoader ).mkToolBox().eval( v )
  </code></pre>
  
  <p>it compiles, but the evaluation fails at runtime with </p>
  
  <pre><code>"scala.tools.reflect.ToolBoxError: reflective compilation has failed: 
  value apply is not a member of &lt;notype&gt;
  [...]
  </code></pre>
  
  <p>Hence the actual type of myfn in the raw AST output is presumably something other than String, but it's not apparent from the API documentation what it might be.</p>
  
  <p>So, can anyone tell me how I construct the required AST?</p>