-
Notifications
You must be signed in to change notification settings - Fork 21
Class-based REPL does not support defining value classes #9910
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
Imported From: https://issues.scala-lang.org/browse/SI-9910?orig=1 |
This has now turned into this. (default REPL in 2.13.2-bin-8ee21e7)
|
Value classes "work" in the class-based REPL by interpreting snippets like |
I'm not sure there's a better way though. Is there a realistic scenario where an object wrapper for a value class can still cause a deadlock? |
Not sure if this is the best place to mention this, but it's possible to have object wrappers without deadlocks, dotty has been doing that for several years: scala/scala-dev#161 (comment) |
IIUC this comes at the cost of capturing the object in the lambda, which can cause problems when serializing the lambda. |
Speaking with Lukas about this, this isn't "resolved", but it's very unlikely we'll actually make this work better in the class-based REPL, so keeping it open is pointless. And I'll take the brownie points too, 🏁. |
Correct, the fix in Dotty was to make all objects extend Serializable. This has ~zero cost since like in Scala 2, Dotty objects use writeReplace to not actually serialize anything. |
So is it a special case only for the REPL? Capturing the repl wrapper is not a problem of course, but capturing arbitrary objects is. |
No it's done for every object (since the same deadlock problem can happen for regular objects too), what kind of problem do you have in mind ? |
OK, so the difference to Scala 2 is that every cc @retronym |
Yep! One additional trick we considered but haven't implemented so far is to add the Serializable superclass in a phase after pickler, so that it does not influence typechecking / type inference seeing as it's "just" an implementation detail. |
Classes extending AnyVal cannot be defined in a REPL started with the
-Yrepl-class-based
option.E.g.
without the -Yrepl-class-based option, everything works as expected.
The text was updated successfully, but these errors were encountered: