diff options
author | Martin Odersky <odersky@gmail.com> | 2012-07-20 16:01:01 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2012-07-20 16:08:25 +0200 |
commit | e0853b3255c5a10793b462c36b62b83963aad17b (patch) | |
tree | 4e9244aa3759ae3fd09c02d39ec336e38911cb3b /test | |
parent | d9b65592df28e8c9655b52c0265f499d757617ba (diff) | |
download | scala-e0853b3255c5a10793b462c36b62b83963aad17b.tar.gz scala-e0853b3255c5a10793b462c36b62b83963aad17b.tar.bz2 scala-e0853b3255c5a10793b462c36b62b83963aad17b.zip |
Removes redundant outers
Widens the criterion when outer fields can be omitted. It used to be that sub- and superclass had to be enclosed by the same outer class. Only in that case was the outer field of the class omitted. We now omit if subclass is contained in an outer class that is itself a subclass of the superclasses outer class.
See test case "outertest.scala" for an example.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/outertest.scala | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/files/run/outertest.scala b/test/files/run/outertest.scala new file mode 100644 index 0000000000..3cc96afa5b --- /dev/null +++ b/test/files/run/outertest.scala @@ -0,0 +1,26 @@ +// A test for the case where the outer field of class B#J should be eliminated. +// You can verify this by running a javap on B.J +abstract class A { + + abstract class I { + + } + + val foo = "foo" + +} + +class B extends A { + + class J extends I { + val bar = foo + } + +} + +object Test extends App { + + val b = new B + assert((new b.J).bar == b.foo) + +} |