-
Notifications
You must be signed in to change notification settings - Fork 21
A var defined in a script not updated after reload in REPL with -Yrepl-class-based #9740
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-9740?orig=1
|
@szeiger said: var X = new {
def x = Seq.empty[AnyRef].reduce((a,b) => a)
} Script: scala -nc -Yrepl-class-based
:load Fail.scala
val a = X
X = null
:load Fail.scala
X
:q |
Jim Powers (corruptmemory) said: If you update the script to: {noformat}scala -nc -Yrepl-class-based You'll see that So, the |
@som-snytt said (edited on Apr 7, 2016 11:01:03 PM UTC): scala> var f: Int => Int = i => i
f: Int => Int = <function1>
scala> val i = f(10)
i: Int = 10
scala> f = null
f: Int => Int = null
scala> var f: Int => Int = i => i
f: Int => Int = <function1>
scala> f // reports the first f, not its redefinition
res0: Int => Int = null Both object and class templates (incorrectly or spuriously) import too much (both first f and i), but object template correctly imports the desired f, which hides the previous f. The class template has different logic that fails to import the correct f at res0, so it resolves to the incorrect one. Imports can require previous imports: scala> trait T ; class C { implicit val t: T = new T {} }
defined trait T
defined class C
scala> val c = new C
c: C = C@77afea7d
scala> import c.t
import c.t
scala> implicitly[T]
res0: T = C$$anon$1@5442a311
scala> val t = 17
t: Int = 17
scala> t
res1: T = C$$anon$1@5442a311 |
@som-snytt said: |
… definition ## What changes were proposed in this pull request? [SPARK-20706](https://issues.apache.org/jira/browse/SPARK-20706): Spark-shell not overriding method/variable definition This is a Scala repl bug ( [SI-9740](scala/bug#9740) ), was fixed in version 2.11.9 ( [see the original PR](scala/scala#5090) ) ## How was this patch tested? Added a new test case in `ReplSuite`. Author: Mark Petruska <[email protected]> Closes apache#19879 from mpetruska/SPARK-20706.
It is possible to produce this problem with the Scala REPL using
-Yrepl-class-based
. The key to triggering this problem seems to be having an anonymous class with at least two members. Included is a new sample file that can be used to exhibit this problem. Below is a session showing the behavior:This has been tested with Scala 2.11.8 and 2.11.7
The text was updated successfully, but these errors were encountered: