You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scala>newCvalres0:C= extantC
scala>classC { overridedeftoString="lineC" }
classC
scala>newCvalres1:C= lineC
scala>:pa -raw
// Entering paste mode (ctrl-D to finish)classC { overridedeftoString="rawC" }
// Exiting paste mode, now interpreting.
scala>newCvalres2:C= lineC
scala>:pa -raw
// Entering paste mode (ctrl-D to finish)packagec { classC { overridedeftoString= "rawC" } }
// Exiting paste mode, now interpreting.
scala>new c.Cvalres4: c.C= rawC
scala>:pa -raw
// Entering paste mode (ctrl-D to finish)packagec { classC { overridedeftoString= "rawC2" } }
// Exiting paste mode, now interpreting.
scala>new c.Cvalres5: c.C= rawC
scala>:reset
Resetting interpreter state.
Forgettingthis session history:
newCclassC { overridedeftoString="lineC" }
newCnewCnew c.Cnew c.CForgetting all expression results and named terms: $intp
Forgetting defined types: C
scala>new c.C
java.lang.NoClassDefFoundError: c/C
at java.lang.Class.getDeclaredMethods0(NativeMethod)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetPublicMethods(Class.java:2902)
at java.lang.Class.getMethods(Class.java:1615)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.evalMethod(IMain.scala:728)
[snip]
Causedby: java.lang.ClassNotFoundException: c.C
at scala.reflect.internal.util.AbstractFileClassLoader.findClass(AbstractFileClassLoader.scala:71)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 27 more
scala>:pa -raw
// Entering paste mode (ctrl-D to finish)packagec { classC { overridedeftoString= "rawC2" } }
// Exiting paste mode, now interpreting.
scala>new c.Cvalres1: c.C= rawC2
Also,
scala> :pa -raw
// Entering paste mode (ctrl-D to finish)
class C { override def toString = "rawC" }
// Exiting paste mode, now interpreting.
scala> new C
val res1: C = extantC
problem
Apparent shadowing is confusing.
An existing class on the class path is "shadowed" by a class in a line package, because REPL scope is consulted first for import candidates. That makes sense, though it might be nice to warn when a logical class name changes provenance.
A rawly pasted class is hidden by an existing class on the class path. That is probably only an issue for default empty package, so maybe keeping it off the class path would be a feature.
You can't redefine a class with raw paste.
:reset has a hiccup as shown.
Maybe what's needed is class loader management to go along with history management (collecting previously computed values).
The text was updated successfully, but these errors were encountered:
scala> :pa -raw
// Entering paste mode (ctrl-D to finish)
class C
// Exiting paste mode, now interpreting.
scala> new C
val res0: C = C@5cd25b58
scala> :pa -raw
// Entering paste mode (ctrl-D to finish)
class C { def foo = 0 }
// Exiting paste mode, now interpreting.
scala> new C().foo
java.lang.NoSuchMethodError: C.foo()I
... 40 elided
dwijnand
changed the title
REPL shadowing is confusing
REPL shadowing broken under :paste -rawNov 18, 2020
fwiw I think of :paste -raw as power-user, hackers-only, you're-on-your-own-here stuff. When I use it, I use it exactly once, at the beginning of a REPL session, and then if I need to change something, I restart the REPL.
reproduction steps
using Scala 2.13.2,
Also,
problem
Apparent shadowing is confusing.
An existing class on the class path is "shadowed" by a class in a line package, because REPL scope is consulted first for import candidates. That makes sense, though it might be nice to warn when a logical class name changes provenance.
A rawly pasted class is hidden by an existing class on the class path. That is probably only an issue for default empty package, so maybe keeping it off the class path would be a feature.
You can't redefine a class with raw paste.
:reset
has a hiccup as shown.Maybe what's needed is class loader management to go along with history management (collecting previously computed values).
The text was updated successfully, but these errors were encountered: