aboutsummaryrefslogtreecommitdiff
path: root/repl
diff options
context:
space:
mode:
authorPrashant Sharma <prashant@apache.org>2014-07-22 00:38:26 -0700
committerPatrick Wendell <pwendell@gmail.com>2014-07-22 00:38:26 -0700
commit81fec9922c5a1a44e086fba450c3eea03cddce63 (patch)
treefac923f4a6e064d9796fd108b737f47b6b1b6d57 /repl
parent5d16d5bbfd242c16ee0d6952c48dcd90651f8ae2 (diff)
downloadspark-81fec9922c5a1a44e086fba450c3eea03cddce63.tar.gz
spark-81fec9922c5a1a44e086fba450c3eea03cddce63.tar.bz2
spark-81fec9922c5a1a44e086fba450c3eea03cddce63.zip
[SPARK-2452] Create a new valid for each instead of using lineId.
Author: Prashant Sharma <prashant@apache.org> Closes #1441 from ScrapCodes/SPARK-2452/multi-statement and squashes the following commits: 26c5c72 [Prashant Sharma] Added a test case. 7e8d28d [Prashant Sharma] SPARK-2452, create a new valid for each instead of using lineId, because Line ids can be same sometimes.
Diffstat (limited to 'repl')
-rw-r--r--repl/src/main/scala/org/apache/spark/repl/SparkImports.scala8
-rw-r--r--repl/src/test/scala/org/apache/spark/repl/ReplSuite.scala11
2 files changed, 17 insertions, 2 deletions
diff --git a/repl/src/main/scala/org/apache/spark/repl/SparkImports.scala b/repl/src/main/scala/org/apache/spark/repl/SparkImports.scala
index bce5c74b9d..9099e052f5 100644
--- a/repl/src/main/scala/org/apache/spark/repl/SparkImports.scala
+++ b/repl/src/main/scala/org/apache/spark/repl/SparkImports.scala
@@ -197,7 +197,7 @@ trait SparkImports {
for (imv <- x.definedNames) {
if (currentImps contains imv) addWrapper()
val objName = req.lineRep.readPath
- val valName = "$VAL" + req.lineRep.lineId
+ val valName = "$VAL" + newValId()
if(!code.toString.endsWith(".`" + imv + "`;\n")) { // Which means already imported
code.append("val " + valName + " = " + objName + ".INSTANCE;\n")
@@ -222,4 +222,10 @@ trait SparkImports {
private def membersAtPickler(sym: Symbol): List[Symbol] =
beforePickler(sym.info.nonPrivateMembers.toList)
+ private var curValId = 0
+
+ private def newValId(): Int = {
+ curValId += 1
+ curValId
+ }
}
diff --git a/repl/src/test/scala/org/apache/spark/repl/ReplSuite.scala b/repl/src/test/scala/org/apache/spark/repl/ReplSuite.scala
index f2aa42dbcb..e2d8d5ff38 100644
--- a/repl/src/test/scala/org/apache/spark/repl/ReplSuite.scala
+++ b/repl/src/test/scala/org/apache/spark/repl/ReplSuite.scala
@@ -235,7 +235,7 @@ class ReplSuite extends FunSuite {
assertContains("res4: Array[Int] = Array(0, 0, 0, 0, 0)", output)
}
- test("SPARK-1199-simple-reproduce") {
+ test("SPARK-1199 two instances of same class don't type check.") {
val output = runInterpreter("local-cluster[1,1,512]",
"""
|case class Sum(exp: String, exp2: String)
@@ -247,6 +247,15 @@ class ReplSuite extends FunSuite {
assertDoesNotContain("Exception", output)
}
+ test("SPARK-2452 compound statements.") {
+ val output = runInterpreter("local",
+ """
+ |val x = 4 ; def f() = x
+ |f()
+ """.stripMargin)
+ assertDoesNotContain("error:", output)
+ assertDoesNotContain("Exception", output)
+ }
if (System.getenv("MESOS_NATIVE_LIBRARY") != null) {
test("running on Mesos") {
val output = runInterpreter("localquiet",