Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make default bridge generation smarter #2520

Open
sjrd opened this issue Jul 11, 2016 · 0 comments
Open

Make default bridge generation smarter #2520

sjrd opened this issue Jul 11, 2016 · 0 comments
Assignees
Labels

Comments

@sjrd
Copy link
Member

@sjrd sjrd commented Jul 11, 2016

Since 2.12.0-M5 does not generate explicit bridges to default methods in classes anymore, the linker has more responsibility in creating default method bridges. But the way it does this is suboptimal. Consider:

trait Foo {
  def foo(): Int = 5
}
class A extends Foo
class B extends A
class C extends A

An ideal solution (and what happened when scalac generated the bridges) is to create the bridge in A:

class A extends Foo {
  def foo(): Int = this.Foo::foo()
}
class B extends A
class C extends A

But the way the linker works for now is a bit stupid, and it will generate bridges in all the instantiated subclasses of A. So if A, B and C are all instantiated, we end up with

class A extends Foo {
  def foo(): Int = this.Foo::foo()
}
class B extends A {
  def foo(): Int = this.Foo::foo()
}
class C extends A {
  def foo(): Int = this.Foo::foo()
}

We should make the default bridge generation smarter so that it generates a bridge in the most appropriate place in the parent chain of a class.

@sjrd sjrd added the enhancement label Jul 11, 2016
@sjrd sjrd self-assigned this Jul 11, 2016
@sjrd sjrd added optimization and removed enhancement labels Jul 22, 2016
@sjrd sjrd added this to the Post-v1.0.0 milestone Oct 11, 2017
@gzm0 gzm0 removed this from the Post-v1.0.0 milestone Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.