- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.1k
Open
Labels
area:specarea:value-classesIssues tied to value classes.Issues tied to value classes.itype:language enhancement
Description
Compiler version
Minimized code
class Bar(val self: Short) extends AnyVal:
    override def equals(that: Any): Boolean = ???
    override def hashCode: Int = ???Output
[[syntax trees at end of                  genBCode]] // playground.scala
package <empty> {
  @SourceFile("playground.scala") final class Bar extends Object {
    def <init>(self: Short): Unit =
      {
        this.self = self
        super()
        ()
      }
    private val self: Short
    def self(): Short = this.self
    override def equals(that: Object): Boolean =
      Bar.equals$extension(this.self(), that)
    override def hashCode(): Int = Bar.hashCode$extension(this.self())
  }
  @SourceFile("playground.scala") final module class Bar extends Object {
    def <init>(): Unit =
      {
        super()
        ()
      }
    private def writeReplace(): Object =
      new scala.runtime.ModuleSerializationProxy(classOf[Bar])
    final def equals$extension($this: Short, that: Object): Boolean = ???()
    final def hashCode$extension($this: Short): Int = ???()
  }
  final lazy module val Bar: Bar = new Bar()
}Compiles.
Expectation
Dotty should prohibit overriding equals and hashCode per the Value Classes's specification; SIP-15:
A value class
Cmust satisfy the following criteria:
...
5.Cmay not define concrete equals or hashCode methods
...
Metadata
Metadata
Assignees
Labels
area:specarea:value-classesIssues tied to value classes.Issues tied to value classes.itype:language enhancement