diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-03-13 11:01:37 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-03-13 11:21:59 +0100 |
commit | 2b5fde7ef9b202e8d4ba94d93d1b91b90e14d42f (patch) | |
tree | 4429c38d56b7de2e740913bf829cd84db863d300 /test/files/run/t7242.scala | |
parent | 52adf130409df57fd612a119e352345cf1c93979 (diff) | |
download | scala-2b5fde7ef9b202e8d4ba94d93d1b91b90e14d42f.tar.gz scala-2b5fde7ef9b202e8d4ba94d93d1b91b90e14d42f.tar.bz2 scala-2b5fde7ef9b202e8d4ba94d93d1b91b90e14d42f.zip |
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 "<console>"
public interface C$T{
public abstract C C$T$$$outer();
}
scala> :javap C.T$
Compiled from "<console>"
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.
Also includes tests from SI-3994, which I'll mark as a duplicate.
Diffstat (limited to 'test/files/run/t7242.scala')
-rw-r--r-- | test/files/run/t7242.scala | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/test/files/run/t7242.scala b/test/files/run/t7242.scala new file mode 100644 index 0000000000..c995336144 --- /dev/null +++ b/test/files/run/t7242.scala @@ -0,0 +1,71 @@ +class CrashTest { + def foo = () + trait CrashTestTable { + def cols = foo + } + // This was leading to a class between the mixed in + // outer accessor and the outer accessor of this object. + object CrashTestTable extends CrashTestTable { + foo + cols + } +} + +class CrashTest1 { + def foo = () + class CrashTestTable { + def cols = foo + } + object CrashTestTable extends CrashTestTable { + foo + cols + } +} + +class CrashTest2 { + def foo = () + trait CrashTestTable { + def cols = foo + } + object Obj extends CrashTestTable { + foo + cols + } +} + +class CrashTest3 { + def foo = () + + def meth() { + trait CrashTestTable { + def cols = foo + } + object Obj extends CrashTestTable { + foo + cols + } + Obj + } +} + +object Test extends App { + { + val c = new CrashTest + c.CrashTestTable + } + + { + val c = new CrashTest1 + c.CrashTestTable + } + + { + val c = new CrashTest2 + c.Obj + } + + { + val c = new CrashTest3 + c.meth() + } +} |