scala/scala — pull request #2750 by retronym (2013-07-18 06:54:43+00:00)
Title: SI-7455 Drop dummy param for synthetic access constructor

Java synthesizes public constructors in private classes to
allow access from inner classes. The signature of
that synthetic constructor (known as a "access constructor")
has a dummy parameter appended to avoid overloading clashes.
javac chooses the type "Enclosing$1" for the dummy parameter
(called the "access constructor tag") which is either an
existing anonymous class or a synthesized class for this purpose.

In OpenJDK, this transformation is performed in:

langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java

(Incidentally, scalac would just emits a byte-code public
constructor in this situation, rather than a private constructor /
access constructor pair.)

Scala parses the signature of the access contructor, and drops
the $outer parameter, but retains the dummy parameter. This causes
havoc when it tries to parse the bytecode for that anonymous class;
the class file parser doesn't have the enclosing type parameters
of Vector in scope and crash ensues.

In any case, we shouldn't allow user code to see that constructor;
it should only be called from within its own compilation unit.

This commit drops the dummy parameter from access constructor
signatures in class file parsing.

Review by @paulp

Targetting 2.10.x. I think this is high reward and relatively low risk.

This bug is often reported by Java 7 Swing users but is unrelated to scala-swing, raw types, or newly-generified Java standard library classes. It could pop up anytime. It is also usually only seen within SBT when its custom compiler phase captures API snapshots.