This change was also important. The problem with Scala's default "wrapper" object for creating one singleton object per line is that the initialization code for that variable needs to run on the workers. For example, say that you type this:

    scala> var x = Console.readLine()
   
    scala> val data = sc.parallelize(1 to 10).map(_ + x)
    
    scala> data.collect()

What Scala will do by default is compile one object for each line, like this:

    object Line1 { var x = Console.readLine() }

And then call it inside subsequent lines:

    object Line3 {
      import Line1.x
      val data = sc.parallelize(1 to 10).map(_ + x)
    }

Unfortunately, since Line1 is a global singleton object, this is a static method call. This means that on the worker node running the map(), Scala will try to run Line1's initializer again, which tries to do Console.readLine. This is bad! Try the current patch against a cluster instead of local mode and you'll see this problem.

My fix in these two methods was to change object Line1 to something like this:

    class Line1 { var x = Console.readLine() }; object Line1 { val INSTANCE = new Line1 }

And then to reference the instance of type Line1 directly inside further lines that use it, instead of going through a static call (code in this method). Luckily, it looks like this aspect of the REPL hasn't changed much in 2.10, so hopefully these changes, plus a few of the others that had MATEI: comments, can be added back.