Fix #1017: Fast MethodDef comparison through hashes

By hashing the method defs the compiler emits, we can calculate more
accurate diffs in the incremental optimizer. This allows us to truly
only re-optimize methods that have changed (and their dependees).

Pseudo-benchmarks have shown that the speed-loss is minor:
~2s on 72s compile time for the whole scalajs library (~2.7%).

The changes to MethodDef made the pattern matcher (or typer) choke,
hence the seemingly unrelated changes to the patterns.
Make it `private` as well. Let us not augment the surface of our Tools API.