Changed ScopingRule to deal with scala scopes

After discussion with @Lewix, we realized we had no mechanism to deal with scala-style symbol scoping, so the ScopingRule base-type now provides symbol scoping functionalities.

I also extended the optimizer macro with ClassDef and ModuleDef since some rules were throwing warnings about this.
Ok, I misunderstood then. What's the equivalent of the current behavior? Or, in other words, when would I need `enterScope` as opposed to just calling `scope`?