summaryrefslogtreecommitdiff
path: root/test/files/run/t6793.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-03-26 10:45:17 +0100
committerJason Zaugg <jzaugg@gmail.com>2013-03-26 15:09:30 +0100
commitca9c8efac5694d6dbfe1d0393c2e7485a01c3ef5 (patch)
tree53acc1cdb05a2754b15aec545838e8a5a830fab2 /test/files/run/t6793.scala
parentfcc22e22248992abffe2506ddef7c0f7c0b23044 (diff)
downloadscala-ca9c8efac5694d6dbfe1d0393c2e7485a01c3ef5.tar.gz
scala-ca9c8efac5694d6dbfe1d0393c2e7485a01c3ef5.tar.bz2
scala-ca9c8efac5694d6dbfe1d0393c2e7485a01c3ef5.zip
SI-6793 Don't use super param accessors if inaccessible.
"Alias replacement" has been with us since 2005 (13c59adf9). Given: package a { class C1(val v0: String) class C2(v1: String) extends a.C1(v1) { v1 } } The reference to `v1` is rewritten as `C2.super.v0()`, and no field is generated in `C2`. (Oddly, this optimization doesn't seem to kick in if these classes are in the empty package. That's probably a distinct bug.) However, this rewriting is done without consideration of the accessibility of `v0` from `C2`. This commit disables this optimization if there if `v0` is not accessible.
Diffstat (limited to 'test/files/run/t6793.scala')
-rw-r--r--test/files/run/t6793.scala9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/files/run/t6793.scala b/test/files/run/t6793.scala
new file mode 100644
index 0000000000..0b1f1619af
--- /dev/null
+++ b/test/files/run/t6793.scala
@@ -0,0 +1,9 @@
+package a { class C1(private[a] val v0: String) }
+package b { class C2(v1: String) extends a.C1(v1) { def foo = v1 } }
+
+object Test extends App {
+ new b.C2("x")
+
+ val c2Fields = classOf[b.C2].getDeclaredFields
+ assert(c2Fields.size == 1, c2Fields.map(_.getName).toList)
+}