Compiler optimizations for Scopes, checkDoubleDefs

Starting with the most valuable commits from:

  https://github.com/retronym/scala/compare/topic;opt20

Review by @gkossakowski