title: Get Name of Reified Function Using Scala Macros
body: <p>I would like to pattern match certain function and other variable references inside a macro traversing over a <code>Tree</code>. Currently, I am matching based on <code>symbol.fullname</code> like this:</p>
  
  <pre class="lang-scala prettyprint-override"><code>tree match {
    case "$f($x)" if f.symbol != null
    &amp;&amp; f.symbol.fullName == "_root_.mypackage.MyClass.myfunc" =&gt;
      ...
    case "$f($x)" if f.symbol != null
    &amp;&amp; f.symbol.fullName == "_root_.mypackage.MyClass2.myfunc2" =&gt;
      ...
  
    case ...
  }
  </code></pre>
  
  <p>However, I would like to additionally check during compilation of this macro that those functions actually exists, e.g. instead of having String, I would like to directly use references, such that the IDE can tell me whether I had a typo in the 'myfunc' name. I was thinking of using using <code>reify</code>, but I am not sure whether that works.</p>
  
  <p>Now lets assume i was looking for <code>println</code> instead of <code>MyClass.myfunc</code>. The first problem I encountered is that you cannot <code>reify(println)</code> or any other function reference directly, because in Scala there are no function references, so you have to write <code>reify(println _)</code> or more specificly in this case <code>reify(println (_: String))</code> to select what println function we want to call. With the following code I collected all symbols that are inside the expression, but sadly only Predef (from Predef.println) is found but not println itself:</p>
  
  <pre class="lang-scala prettyprint-override"><code>println(reify( println (_:String) ).tree
         .collect { case x if x.symbol != null =&gt; x.symbol.fullName } )
  // List(&lt;none&gt;, &lt;none&gt;, &lt;none&gt;, scala.Predef, &lt;none&gt;, &lt;none&gt;, scala.Predef, &lt;none&gt;, &lt;none&gt;, scala.Predef)
  </code></pre>
  
  <p>Any ideas for getting the name of something in scala (currently using 2.12)?</p>