Skip to content

Trait can redefine the final methods from a class AnyRef #3442

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
maseev opened this issue Nov 8, 2017 · 2 comments
Closed

Trait can redefine the final methods from a class AnyRef #3442

maseev opened this issue Nov 8, 2017 · 2 comments

Comments

@maseev
Copy link
Contributor

maseev commented Nov 8, 2017

Doing this:

scala> trait Fun {
         override def notify(): Unit = {
         }
       } 
// defined trait Fun
scala> class MyClass extends Fun 
// defined class MyClass
scala> new MyClass 

kills the REPL with this:

Exception in thread "main" java.lang.VerifyError: class rs$line$1$Fun overrides final method notify.()V
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:642)
        at dotty.tools.repl.AbstractFileClassLoader.findClass(AbstractFileClassLoader.scala:28)
        at dotty.tools.repl.AbstractFileClassLoader.loadClass(AbstractFileClassLoader.scala:32)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:642)
        at dotty.tools.repl.AbstractFileClassLoader.findClass(AbstractFileClassLoader.scala:28)
        at dotty.tools.repl.AbstractFileClassLoader.loadClass(AbstractFileClassLoader.scala:32)
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.getDeclaredMethods(Class.java:1975)
        at dotty.tools.repl.Rendering.valueOf(Rendering.scala:56)
        at dotty.tools.repl.Rendering.renderVal(Rendering.scala:79)
        at dotty.tools.repl.ReplDriver.displayMembers$3$$anonfun$3(ReplDriver.scala:269)
        at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
        at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:59)
        at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:52)
        at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
        at scala.collection.TraversableLike.map(TraversableLike.scala:234)
        at scala.collection.TraversableLike.map$(TraversableLike.scala:227)
        at scala.collection.AbstractTraversable.map(Traversable.scala:104)
        at dotty.tools.repl.ReplDriver.displayMembers$7(ReplDriver.scala:269)
        at dotty.tools.repl.ReplDriver.displayDefinitions$$anonfun$3$$anonfun$2(ReplDriver.scala:296)
        at scala.Option.map(Option.scala:146)
        at dotty.tools.repl.ReplDriver.displayDefinitions$$anonfun$1(ReplDriver.scala:296)
        at dotty.tools.dotc.core.Periods.atPhase(Periods.scala:26)
        at dotty.tools.dotc.core.Phases.atPhase(Phases.scala:36)
        at dotty.tools.repl.ReplDriver.displayDefinitions(ReplDriver.scala:301)
        at dotty.tools.repl.ReplDriver.compile$$anonfun$2(ReplDriver.scala:226)
        at scala.util.Either.fold(Either.scala:188)
        at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:227)
        at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:190)
        at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:143)
        at dotty.tools.repl.Main$.main(Main.scala:6)
        at dotty.tools.repl.Main.main(Main.scala)

I guess the compiler should check this case somewhere here, but apparently, it does not.

@allanrenucci
Copy link
Contributor

scala/scala@88ed763 should be ported to our fork of scala at https://github.com/lampepfl/scala/tree/dotty-library

@smarter
Copy link
Member

smarter commented Nov 8, 2017

Nice catch! :)

scala/scala@88ed763 should be ported to our fork of scala at https://github.com/lampepfl/scala/tree/dotty-library

That shouldn't matter for this particular issue since we run dotty with the scala-library from 2.12.

nicolasstucki added a commit that referenced this issue Nov 8, 2017
Fix #3442: Make `wait`, `notify` and `notifyAll` final
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants