-
Notifications
You must be signed in to change notification settings - Fork 21
Classes defined in the REPL have no default constructor #12032
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
Comments
You want to turn off the option:
|
Here's the summary of -Yrepl-class-based and the recent changes around it scala/scala#8712.
Specifically for classes, it's not inherent that they are wrapped in classes - there's no impact on serialising REPL state nor impact in deadlocking. In the aggregate, it might create more confusion to have more variants that opt-out of class-based wrapping, which right now is just value classes. Also, there's the issue of what to do when there are multiple "things" defined, like |
I thought final classes avoided this outer pointer stuff, but apparently the pointer still gets passed to the constructor. It just doesn't get stored in a field.
|
oops, thanks for the correction, I was just confused before |
"raw hide". |
Thank you very much for your fast responses. Using > scala -Yrepl-class-based:false -cp "lib/*"
Welcome to Scala 2.13.2 (OpenJDK 64-Bit Server VM, Java 13.0.1).
Type in expressions for evaluation. Or try :help.
scala> import akka.actor._
| val as = ActorSystem("as")
| class PrintActor extends Actor {
| def receive = { case msg: Int => println(msg) }
| }
| val printActor: ActorRef = as.actorOf(Props[PrintActor])
import akka.actor._
val as: akka.actor.ActorSystem = akka://as
class PrintActor
val printActor: akka.actor.ActorRef = Actor[akka://as/user/$a#-611164863] I let the issue |
reproduction steps
using Scala 2.13.2, when defining a class in the REPL, no default constructor is generated. Instead there is only the constructor which expects the reference to the surrounding object.
This was different in 2.13.1:
problem
I used to show akka examples in the repl for a course I am teaching. With Scala 2.13.2 it does not work anymore. I guess
Props[PrintActor]
searches for the zero argument constructor ofPrintActor
to create an instance - and can not find it.The example above works as expected with Scala 2.13.1.
Random note:
-Yrepl-class-based
does not help.The text was updated successfully, but these errors were encountered: