diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-03-14 12:50:52 +0400 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-03-23 15:39:57 +0100 |
commit | cd9e03af8d61e7def5df2a0958de31ca0c163780 (patch) | |
tree | 1b5f0eaa8bbb6903c753abb70da60a9d4a7c1213 /test/files/run/t7246b | |
parent | b7b4f877326acd6a8a24ff60fa1638cc18143c45 (diff) | |
download | scala-cd9e03af8d61e7def5df2a0958de31ca0c163780.tar.gz scala-cd9e03af8d61e7def5df2a0958de31ca0c163780.tar.bz2 scala-cd9e03af8d61e7def5df2a0958de31ca0c163780.zip |
SI-7246 Make $outer pointer elision Java aware
In e0853b3, a space-saving optimization elided the outer pointer
of inner classes if the the (protected) outer pointer of the
immediate parent class was guaranteed to point to the same instance.
But, this check failed to account for Java parent classes, which
don't follow the Scala scheme. This commit disables the optimization
in that case.
The original test case in e0853b3 was anemic, I've fleshed it out to:
- test the presense or absense of $outer pointers with Java reflection
- test the optimization works in the presense of aliased and annotated
aliased types. (The former worked already, the latter required a
change to the implementation.)
- Test the negative case when the prefixes don't line up and the
subclass in fact needs its own $outer.
This patch is based on work by Euguene Vigdorchik with some
additions by Jason Zaugg.
Diffstat (limited to 'test/files/run/t7246b')
-rwxr-xr-x | test/files/run/t7246b/Base.scala | 7 | ||||
-rwxr-xr-x | test/files/run/t7246b/Outer.java | 4 | ||||
-rwxr-xr-x | test/files/run/t7246b/Test.scala | 14 |
3 files changed, 25 insertions, 0 deletions
diff --git a/test/files/run/t7246b/Base.scala b/test/files/run/t7246b/Base.scala new file mode 100755 index 0000000000..4e71d3313d --- /dev/null +++ b/test/files/run/t7246b/Base.scala @@ -0,0 +1,7 @@ +class Base { + val baseOuter = "base" + + class BaseInner { + val baseInner = baseOuter + } +} diff --git a/test/files/run/t7246b/Outer.java b/test/files/run/t7246b/Outer.java new file mode 100755 index 0000000000..53a79316ef --- /dev/null +++ b/test/files/run/t7246b/Outer.java @@ -0,0 +1,4 @@ +public class Outer extends Base { + public class Inner extends BaseInner { + } +}
\ No newline at end of file diff --git a/test/files/run/t7246b/Test.scala b/test/files/run/t7246b/Test.scala new file mode 100755 index 0000000000..f0982ea8d0 --- /dev/null +++ b/test/files/run/t7246b/Test.scala @@ -0,0 +1,14 @@ +object Test extends App { + + val so = new SubOuter + val si = new so.SubInner + println(si.baseInner) + println(si.subInner) +} + +class SubOuter extends Outer { + val subOuter = "sub" + class SubInner extends Inner { + def subInner = subOuter + } +} |