diff options
author | Eugene Vigdorchik <eugene.vigdorchik@gmail.com> | 2013-03-17 16:31:45 +0400 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-03-25 10:58:26 -0700 |
commit | 4e10b2c833fa846c68b81e94a08d867e7de656aa (patch) | |
tree | a70fc22c2330c5c00d8e787d0d54065842034355 /test/files | |
parent | b7b4f877326acd6a8a24ff60fa1638cc18143c45 (diff) | |
download | scala-4e10b2c833fa846c68b81e94a08d867e7de656aa.tar.gz scala-4e10b2c833fa846c68b81e94a08d867e7de656aa.tar.bz2 scala-4e10b2c833fa846c68b81e94a08d867e7de656aa.zip |
SI-6387 Clones accessor before name expansion
When a symbol's name is expanded due to a conflict during
composition (e.g. multiple traits with same-named members, but
which are not both visible at the language level in the concrete
class) the compiler renames some symbols with expanded names which
embed the full name of the declaring class to avoid clashes.
In the rare cases when the accessor overrides the member in base
class, such expansion either results in AbstractMethodError when
the base method is abstract, or, even worse, can change the
semantics of the program.
To avoid such issues, we clone the accessor symbol, clear its
ACCESSOR flag and enter the symbol with an unchanged name.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/t6387.check | 1 | ||||
-rw-r--r-- | test/files/run/t6387.scala | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/test/files/run/t6387.check b/test/files/run/t6387.check new file mode 100644 index 0000000000..83b33d238d --- /dev/null +++ b/test/files/run/t6387.check @@ -0,0 +1 @@ +1000 diff --git a/test/files/run/t6387.scala b/test/files/run/t6387.scala new file mode 100644 index 0000000000..bbebb5f511 --- /dev/null +++ b/test/files/run/t6387.scala @@ -0,0 +1,16 @@ +trait A { + def foo: Long +} + +object Test { + def a(): A = new A { + var foo: Long = 1000L + + val test = () => { + foo = 28 + } + } + def main(args: Array[String]) { + println(a().foo) + } +} |