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

ParamForwarding: questions #783

Closed
DarkDimius opened this issue Sep 7, 2015 · 2 comments
Closed

ParamForwarding: questions #783

DarkDimius opened this issue Sep 7, 2015 · 2 comments

Comments

@DarkDimius
Copy link
Contributor

https://github.com/lampepfl/dotty/blob/master/src/dotty/tools/dotc/transform/ParamForwarding.scala#L22

/** For all parameter accessors
 *
 *      val x: T = ...
 *
 *  if
 *  (1) x is forwarded in the supercall to a parameter that's also named `x`
 *  (2) the superclass parameter accessor for `x` is accessible from the current class
 *  change the accessor to
 *
 *    def x: T = super.x.asInstanceOf[T]
 *
 *  Do the same also if there are intermediate inaccessible parameter accessor forwarders.
 *  The aim of this transformation is to avoid redundant parameter accessor fields.
 */

I have several questions to what this phase does:

  1. Why do names matter?
  2. if indeed name has not changed, is not it better to remove def entirely? Than virtual dispatch will do the same that def x: T = super.x.asInstanceOf[T] does. (I guess the answer is that types could be different, but I want to make sure that there are no other reasons)
@odersky
Copy link
Contributor

odersky commented Sep 8, 2015

Why do names matter?

To limit the search space, and make it more predictable.

if indeed name has not changed, is not it better to remove def entirely? Than virtual dispatch will do the same that def x: T = super.x.asInstanceOf[T] does. (I guess the answer is that types could be different, but I want to make sure that there are no other reasons)

And we also need a witness for the parameter accessor later on (that's something pickling/unpickling needs, for instance)

@DarkDimius
Copy link
Contributor Author

And we also need a witness for the parameter accessor later on (that's something pickling/unpickling needs, for instance)

@odersky following examples from #776 scalac does not create such method. The examples in #776 also suggest that we cannot create def x, as either private or protected or public or default. We either need to remove the method(as scalac does) or to name mangle it.

DarkDimius added a commit to dotty-staging/dotty that referenced this issue Sep 20, 2015
DarkDimius added a commit that referenced this issue Sep 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants