Skip to content

Symbols' owner are not always up to date #518

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

Closed
smarter opened this issue May 1, 2015 · 1 comment · Fixed by #534
Closed

Symbols' owner are not always up to date #518

smarter opened this issue May 1, 2015 · 1 comment · Fixed by #534

Comments

@smarter
Copy link
Member

smarter commented May 1, 2015

For example:

class Meter(val underlying: Int) extends AnyVal

class Test {
  val x: Int = new Meter(3).hashCode() 
}

new Meter(3).hashCode() should be replaced by Meter.hashCode$extension(3) in phase VCInline but it isn't because isMethodWithExtension returns false for hashCode because its owner is Any. This is incorrect because the phase SyntheticMethods will add an hashCode method to Meter. For value classes this problem can only happen with hashCode and equals (and a few other methods if the value class is also a case class), so I could work around it by hardcoding these methods into isMethodWithExtension, but maybe it's worth solving the underlying problem, I don't know what consequences it could have.

@DarkDimius
Copy link
Contributor

Changes that should follow merging #515 should change how SyntheticMethods handles value classes.

SyntheticMethods already specially handles synthesis of every method for value class. After #515 gets merged, there would be less methods to synthesize and thus less special handling.

odersky added a commit to dotty-staging/dotty that referenced this issue May 4, 2015
odersky added a commit that referenced this issue May 5, 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

Successfully merging a pull request may close this issue.

2 participants