lampepfl/dotty — pull request #68 by odersky (2014-03-13 14:34:01+00:00)
Title: Try/hygienic desugaring

Desugaring is now hygienic.

Desugaring involves copying things in new scopes. Example: Constructor parameters of an implicit case class are copied to (1) the apply method in the companion object (2) the copy method in the class itself, (3) the implicit wrapper in the enclosing scope, and (4) type parameters are also copied to the unapply method in the companion object. It is important that the types of these parameters are all resolved in the same context as the constructor parameter. Otherwise name clashes can result, or, what's worse, things can be resolved in the wrong context. A particular bad case arises if an inner class inherits some generic instance of its outer class. In that case it makes a big difference whether something is resolved in the class or outside of it.

At the same time, we cannot simply copy full types, because the local copies might contain references to redefined type parameters and term parameters which need to be re-bound.

The present pull request achieves all that. And except for some general logic, it is local to Desugar, no cooperation of Namer or Typer is needed. As a bonus, we get a more principled treatment of getter parameters which does not require Namer cooperation.