scala/scala — pull request #2245 by retronym (2013-03-13 10:14:44+00:00)
Title: SI-7242 Fix crash when inner object mixes in its companion

Given:

class C {
trait T { C.this } // C$T$$$outer$ : C
object T extends T { C.this } // C$T$$$outer$ : C.this.type
}

object T ended up with a definitions for both of the accessors.
These cannot co-exist, as they have the same erased type. A crash
ensued almost immediately in explitouter.

Fortunately, the solution is straightforward: we can just omit
the mixin outer accessor altogether, the objects own outer accessor
is compatible with it.

scala> :javap C.T
Compiled from ""
public interface C$T{
public abstract C C$T$$$outer();
}

scala> :javap C.T$
Compiled from ""
public class C$T$ extends java.lang.Object implements C$T{
public C C$T$$$outer();
public C$T$(C);
}

I also added an assertion to give a better error message in
case we find ourselves here again.

Review by @paulp. I can't find any duplicates of the bug in JIRA, but it seems so easy to step into that I'm sure they must be in there. Can you summon any?