From 4e10b2c833fa846c68b81e94a08d867e7de656aa Mon Sep 17 00:00:00 2001 From: Eugene Vigdorchik Date: Sun, 17 Mar 2013 16:31:45 +0400 Subject: 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. --- test/files/run/t6387.check | 1 + test/files/run/t6387.scala | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 test/files/run/t6387.check create mode 100644 test/files/run/t6387.scala (limited to 'test/files/run') 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) + } +} -- cgit v1.2.3