diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 8444226c00a4..8fbb60f99c88 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -565,7 +565,7 @@ abstract class Erasure extends InfoTransform if (!bridgeNeeded) return - var newFlags = (member.flags | BRIDGE | ARTIFACT) & ~(ACCESSOR | DEFERRED | LAZY) + var newFlags = (member.flags | BRIDGE | ARTIFACT) & ~(ACCESSOR | DEFERRED | LAZY | FINAL) // If `member` is a ModuleSymbol, the bridge should not also be a ModuleSymbol. Otherwise we // end up with two module symbols with the same name in the same scope, which is surprising // when implementing later phases. diff --git a/test/files/run/t12532.scala b/test/files/run/t12532.scala new file mode 100644 index 000000000000..f220068d99c5 --- /dev/null +++ b/test/files/run/t12532.scala @@ -0,0 +1,27 @@ +class Sync + +class Async extends Sync { def x = 1 } + +trait Base { + def foo: Sync +} + +trait BaseSync extends Base { + override def foo: Sync +} + +trait BaseAsync extends Base { + override def foo: Async +} + +abstract class ImplAsync extends BaseAsync { + final override def foo: Async = new Async +} + +final class StrangeClass extends ImplAsync with BaseSync + +object Test { + def main(args: Array[String]): Unit = { + assert((new StrangeClass).foo.x == 1) + } +} \ No newline at end of file diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check index b1b55b3cbf62..771a7cbff201 100644 --- a/test/files/run/t6028.check +++ b/test/files/run/t6028.check @@ -33,7 +33,7 @@ package { def apply$mcI$sp(): Int = $anonfun$foo$1.this.$outer.classParam.+($anonfun$foo$1.this.$outer.field()).+($anonfun$foo$1.this.methodParam$1).+($anonfun$foo$1.this.methodLocal$1); private[this] val $outer: T = _; def $outer(): T = $anonfun$foo$1.this.$outer; - final def apply(): Object = scala.Int.box($anonfun$foo$1.this.apply()); + def apply(): Object = scala.Int.box($anonfun$foo$1.this.apply()); private[this] val methodParam$1: Int = _; private[this] val methodLocal$1: Int = _ }; @@ -73,7 +73,7 @@ package { } finally (); private[this] val $outer: T = _; def $outer(): T = $anonfun$tryy$1.this.$outer; - final def apply(): Object = { + def apply(): Object = { $anonfun$tryy$1.this.apply(); scala.runtime.BoxedUnit.UNIT };