bug icon indicating copy to clipboard operation
bug copied to clipboard

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

Open hrhino opened this issue 8 years ago • 0 comments

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.

hrhino avatar Nov 23 '17 01:11 hrhino