Skip to content
Snippets Groups Projects
Commit 81fec992 authored by Prashant Sharma's avatar Prashant Sharma Committed by Patrick Wendell
Browse files

[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.
parent 5d16d5bb
No related branches found
No related tags found
No related merge requests found
...@@ -197,7 +197,7 @@ trait SparkImports { ...@@ -197,7 +197,7 @@ trait SparkImports {
for (imv <- x.definedNames) { for (imv <- x.definedNames) {
if (currentImps contains imv) addWrapper() if (currentImps contains imv) addWrapper()
val objName = req.lineRep.readPath 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 if(!code.toString.endsWith(".`" + imv + "`;\n")) { // Which means already imported
code.append("val " + valName + " = " + objName + ".INSTANCE;\n") code.append("val " + valName + " = " + objName + ".INSTANCE;\n")
...@@ -222,4 +222,10 @@ trait SparkImports { ...@@ -222,4 +222,10 @@ trait SparkImports {
private def membersAtPickler(sym: Symbol): List[Symbol] = private def membersAtPickler(sym: Symbol): List[Symbol] =
beforePickler(sym.info.nonPrivateMembers.toList) beforePickler(sym.info.nonPrivateMembers.toList)
private var curValId = 0
private def newValId(): Int = {
curValId += 1
curValId
}
} }
...@@ -235,7 +235,7 @@ class ReplSuite extends FunSuite { ...@@ -235,7 +235,7 @@ class ReplSuite extends FunSuite {
assertContains("res4: Array[Int] = Array(0, 0, 0, 0, 0)", output) 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]", val output = runInterpreter("local-cluster[1,1,512]",
""" """
|case class Sum(exp: String, exp2: String) |case class Sum(exp: String, exp2: String)
...@@ -247,6 +247,15 @@ class ReplSuite extends FunSuite { ...@@ -247,6 +247,15 @@ class ReplSuite extends FunSuite {
assertDoesNotContain("Exception", output) 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) { if (System.getenv("MESOS_NATIVE_LIBRARY") != null) {
test("running on Mesos") { test("running on Mesos") {
val output = runInterpreter("localquiet", val output = runInterpreter("localquiet",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment