It's more difficult, because Scala reflection does more and need more. For example:
- The types are not erased. The classes are erased, but not the types.
- Scala supports named parameters, so you need the name of the parameters.
- Scala has methods without parameter lists.
So, given all that, here's how you do it. First, get the methods:
val stringMethods: Iterable[MethodSymbol] = typeOf[String].members.collect {
case m if m.isMethod => m.asMethod
}
Scala reflection doesn't (yet) provide methods to list specific kinds of members (methods, fields, inner classes, etc), so you need to use the general members method.
Working for all kinds of members, the members method returns an iterable of Symbol, the greatest common denominator of all symbols, so you'll need to cast to MethodSymbol to treat the resulting symbols as methods.
Now, let's say we have a MethodSymbol, and we want the types of arguments. We can do this:
method.paramLists