title: How to filter methods by return type with scala reflection?
body: <p>I'm trying to test whether a method's return type exactly matches a supplied type.</p>
  
  <p>Somehow, I've found two String Types that are not equal. </p>
  
  <pre><code>class VarAndValue {
    @BeanProperty
    val value = "";    
  }
  
  class ScalaReflectionTest {
  
    @Test
    def myTest(): Unit = {
  
      val type1 = universe.typeOf[String]
  
      // Get return value of VarAndValue.getValue
      val type2 = universe.typeOf[VarAndValue].
        declarations.
        filter { m =&gt; m.name.decoded == "getValue" &amp;&amp; m.isMethod }.
        head.
        asInstanceOf[universe.MethodSymbol].
        returnType
  
        println(type1)   // String
        println(type2)   // String
        println(type1.getClass())
        println(type2.getClass()) // !=type1.getClass()   !!
        println(type1==type2)     // False
     }
  }
  </code></pre>
  
  <p>yields...</p>
  
  <pre><code>String
  String
  class scala.reflect.internal.Types$TypeRef$$anon$3
  class scala.reflect.internal.Types$TypeRef$$anon$6
  false
  </code></pre>
  
  <p>How can I filter methods of a class by their return type? (It seems very difficult if I can test for equality of the return types).</p>
  
  <p>Scala 2.10</p>
  
  <p>UPDATE: </p>
  
  <p>I can't drop into the Java reflection universe because this erased type information for generics like List[Int] (which become List[Object] is java-land where they're really List[java.lang.Integer]). I need my matched to pay attention to the generic parameter information that the scala type universe preserves.</p>