From c82bc67737a31f2a639172e677cafdefe8fdbf4e Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sat, 26 May 2012 22:49:12 +0200 Subject: Fix a NSDNHAO in extension methods. A bridge method, created when we override a method from a superclass and refine the return type, was appearing as an overloaded alternative. (`erasure` doesn't create new scopes, so the bridges it builds are visible at earlier phases.) The problem was masked when compiling with specialization, which *does* create a new scope, shielding the code in question from the artefacts of erasure. To fix the problem, we filter out bridge methods from the overloaded alternatives returned by `.decl`, as would happen internally in `.member`. --- test/files/pos/value-class-override-no-spec.flags | 1 + test/files/pos/value-class-override-no-spec.scala | 9 +++++++++ test/files/pos/value-class-override-spec.scala | 9 +++++++++ 3 files changed, 19 insertions(+) create mode 100644 test/files/pos/value-class-override-no-spec.flags create mode 100644 test/files/pos/value-class-override-no-spec.scala create mode 100644 test/files/pos/value-class-override-spec.scala (limited to 'test/files') diff --git a/test/files/pos/value-class-override-no-spec.flags b/test/files/pos/value-class-override-no-spec.flags new file mode 100644 index 0000000000..a7e64e4f0c --- /dev/null +++ b/test/files/pos/value-class-override-no-spec.flags @@ -0,0 +1 @@ +-no-specialization \ No newline at end of file diff --git a/test/files/pos/value-class-override-no-spec.scala b/test/files/pos/value-class-override-no-spec.scala new file mode 100644 index 0000000000..79de5d9305 --- /dev/null +++ b/test/files/pos/value-class-override-no-spec.scala @@ -0,0 +1,9 @@ +// There are two versions of this tests: one with and one without specialization. +// The bug was only exposed *without* specialization. +trait T extends Any { + def x: Any +} + +final class StringOps(val repr0: String) extends AnyVal with T { + def x = () +} diff --git a/test/files/pos/value-class-override-spec.scala b/test/files/pos/value-class-override-spec.scala new file mode 100644 index 0000000000..79de5d9305 --- /dev/null +++ b/test/files/pos/value-class-override-spec.scala @@ -0,0 +1,9 @@ +// There are two versions of this tests: one with and one without specialization. +// The bug was only exposed *without* specialization. +trait T extends Any { + def x: Any +} + +final class StringOps(val repr0: String) extends AnyVal with T { + def x = () +} -- cgit v1.2.3