scala/scala — pull request #2664 by retronym (2013-06-19 20:40:24+00:00)
Title: SI-7596 Curtail overloaded symbols during unpickling

In code like:

object O { val x = A; def x(a: Any) = ... }
object P extends O.x.A

The unpickler was using an overloaded symbol for `x` in the
parent type of `P`. This led to compilation failures under
separate compilation.

The code that leads to this is in `Unpicklers`:

def fromName(name: Name) = name.toTermName match {
case nme.ROOT => loadingMirror.RootClass
case nme.ROOTPKG => loadingMirror.RootPackage
case _ => adjust(owner.info.decl(name))
}

This commit filters the overloaded symbol based on the
parameter list size when unpickling a singleton type.
That seemed a slightly safer place than in `fromName`.

Review by @gkossakowski

Points for review:
- where do you think the right place is to filter the symbol?
- I chose `filter` over `suchThat` to defer errors in the case that the val no longer exists. But I didn't test that case, and don't really think the precise error mode is too important; things will blow up quickly either way.