scala/scala — pull request #2334 by vigdorchik (2013-03-29 10:33:07+00:00)
Title: SI-7202 tighten name mangling.

Following the discussion at https://groups.google.com/forum/?fromgroups=#!searchin/scala-internals/mangling/scala-internals/GHC3HJTegmw/5py5GH7Rrm8J
I'm re-submitting the change against master.

When the compiler wants to make private symbol visible outside its
declaring class, it also changes the name to make it unique to avoid
accidental overriding.

The current scheme prepends fullName of the owner class, which could
still result in overriding if the derived class is nested in a value
definition.

To avoid such scenario, name mangling prepends not only the names of
the enclosing classes, but also '$' characters for val owners that
aren't synthetic.

This scheme wouldn't be enough if the base class were local as well,
and the derived class saw it with a non-trivial prefix type; however
scala doesn't allow it.

Making this change required unification between normal 'fullName'
and the one used for name mangling. Using the opportunity, I also
clean the implementation of fullName to make recurring local, that
is a speedup over the late-bound call currently.