title: Function type definition and type erasure in Scala
body: <p>Given the following type and instance:</p>
  
  <pre><code>type operation = (Int, Int) =&gt; Int
  def add: operation = _ + _
  </code></pre>
  
  <p>If I try to match an operation in a case statement, Scala complains about unchecked typing due to type erasure:</p>
  
  <pre><code>for (a &lt;- elements) a match {
    case o: operation =&gt; // do stuff
  }
  </code></pre>
  
  <p>Is there a way to achieve this kind of function-based typing while being erasure-friendly in case statements?</p>
  
  <p>Note, this is similar to <a href="https://stackoverflow.com/questions/1853868/how-do-you-define-a-type-for-a-function-in-scala">this thread</a>.</p>