Skip to content

Commit

Permalink
Emit all bridge methods non-final
Browse files Browse the repository at this point in the history
  • Loading branch information
lrytz committed Mar 17, 2022
1 parent cd6cd30 commit 62f18e6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/transform/Erasure.scala
Expand Up @@ -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.
Expand Down
27 changes: 27 additions & 0 deletions 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)
}
}

0 comments on commit 62f18e6

Please sign in to comment.