Skip to content

scala doesn't forbid super.##, if you're in a universal trait / value class #10624

Open
@hrhino

Description

@hrhino

And it should, because it won't work:

scala> class Meh(val i: Int) extends AnyVal { def q = super.## }
defined class Meh

scala> new Meh(1).q
java.lang.NoSuchMethodError: java.lang.Object.$hash$hash()I
  at Meh.$line3$$read$Meh$$super$$hash$hash(<console>:11)

Non-value classes get errors, not crashes.

scala> class Meh(val i: Int) { def q = super.## }
<console>:11: error: super not allowed here: use this.## instead
       class Meh(val i: Int) { def q = super.## }
                                             ^

This is a value-class-induced re-introduction of #3736.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions