Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upA var defined in a script not updated after reload in REPL with -Yrepl-class-based #9740
Comments
This comment has been minimized.
This comment has been minimized.
Imported From: https://issues.scala-lang.org/browse/SI-9740?orig=1
|
This comment has been minimized.
This comment has been minimized.
@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 |
This comment has been minimized.
This comment has been minimized.
Jim Powers (corruptmemory) said: If you update the script to: {noformat}scala -nc -Yrepl-class-based You'll see that So, the |
This comment has been minimized.
This comment has been minimized.
@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 |
This comment has been minimized.
This comment has been minimized.
@som-snytt said: |
scabug commentedApr 6, 2016
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