Skip to content

Commit 72643d9

Browse files
rxinhvanhovell
authored andcommitted
[PROD-1622][PROD-8140] Backport SI-9734 for Scala 2.10
This was done by zsxwing in databricks/universe@462da3a (cherry picked from commit b7555a5b947ee41ee017ac5d0be78795868ff54f) Signed-off-by: Herman van Hovell <hvanhovelldatabricks.com> Author: Reynold Xin <[email protected]> Closes apache#121 from hvanhovell/PROD-1622-21.
1 parent 448a8b7 commit 72643d9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

repl/scala-2.10/src/main/scala/org/apache/spark/repl/SparkImports.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ private[repl] trait SparkImports {
190190
val valName = "$VAL" + newValId();
191191

192192
if(!code.toString.endsWith(".`" + imv + "`;\n")) { // Which means already imported
193-
code.append("val " + valName + " = " + objName + ".INSTANCE;\n")
193+
code.append(s"val $valName: ${objName}.INSTANCE.type = ${objName}.INSTANCE;\n")
194194
code.append("import " + valName + req.accessPath + ".`" + imv + "`;\n")
195195
}
196196
// code.append("val " + valName + " = " + objName + ".INSTANCE;\n")

repl/scala-2.10/src/test/scala/org/apache/spark/repl/ReplSuite.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,5 +355,16 @@ class ReplSuite extends SparkFunSuite {
355355
assertDoesNotContain("Exception", output)
356356
assertContains("ret: Array[(Int, Iterable[Foo])] = Array((1,", output)
357357
}
358+
359+
test("SI-9734 class defined with paste mode mismatches") {
360+
val output = runInterpreter("local",
361+
"""
362+
|case class Data(i: Int); val d = Data(1)
363+
|val d2: Data = d
364+
""".stripMargin)
365+
assertDoesNotContain("error:", output)
366+
assertDoesNotContain("Exception", output)
367+
assertContains("d2: Data = Data(1)", output)
368+
}
358369
}
359370

0 commit comments

Comments
 (0)