Skip to content

Conversation

@smarter
Copy link
Member

@smarter smarter commented Feb 14, 2015

@odersky or @DarkDimius : please review.

@smarter smarter force-pushed the fix/value-classes-methods branch from 1f54c6d to c587662 Compare February 14, 2015 23:27
Before this commit, the following class:
  class VC(val x: Int) extends AnyVal
resulted in the creation of the method:
  def equals(val x$0: Any): Boolean =
    x$0 match {
      case x$0 @ _: VC => true
      case _: Any => false
    }
After this commit, we get instead:
  def equals(val x$0: Any): Boolean =
    x$0 match {
      case x$0 @ _: VC => VC.this.a.==(x$0.a)
      case _: Any => false
    }
@smarter smarter force-pushed the fix/value-classes-methods branch from c587662 to 0ed32fa Compare February 14, 2015 23:48
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used appliedToNone to avoid errors like:

type mismatch:
 found   : ()Int($this.a.hashCode)
 required: Int

But this breaks dotc_core with:

error: method hashCode in class TermName does not take parameters

Any idea what the proper way to fix this is?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My assumption is that some of hashcodes you see are ExprTypes and other ones are MethodTypes.
look for ensureApplied in codebase.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ensureApplied seems to do the trick, thanks.

Before this commit, we used the same implementation than for case classes.
After this commit, we use the hashCode of the underlying type as defined
in SIP-15.
@smarter smarter force-pushed the fix/value-classes-methods branch from 0ed32fa to b1d6de2 Compare February 17, 2015 12:24
@DarkDimius DarkDimius self-assigned this Feb 17, 2015
DarkDimius added a commit that referenced this pull request Feb 17, 2015
Fix the synthetic methods of value classes
@DarkDimius DarkDimius merged commit 34853b3 into scala:master Feb 17, 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 this pull request may close these issues.

2 participants