summaryrefslogtreecommitdiff
path: root/src/repl
diff options
context:
space:
mode:
authorAntoine Gourlay <antoine@gourlay.fr>2013-08-18 17:38:53 +0200
committerAntoine Gourlay <antoine@gourlay.fr>2013-08-18 17:38:53 +0200
commit654fdb1f84ffff2c5b3c0b0eabc1fdd3946eec83 (patch)
treef57e6ac97830a37c0dc04ee2929aa6ef18d47e9d /src/repl
parent6db8a523e32c093c70b27797628bacbda78b81bb (diff)
downloadscala-654fdb1f84ffff2c5b3c0b0eabc1fdd3946eec83.tar.gz
scala-654fdb1f84ffff2c5b3c0b0eabc1fdd3946eec83.tar.bz2
scala-654fdb1f84ffff2c5b3c0b0eabc1fdd3946eec83.zip
SI-6507 completely sidestep handlers in REPL when :silent in on
This is a cleanup of 6db8a52, the original fix for SI-6507. When the REPL is :silent, all handlers are ignored when it comes to generating the printed result. The result extraction code (`lazy val resN = ...`) is still generated, but now it isn't called until the user calls it.
Diffstat (limited to 'src/repl')
-rw-r--r--src/repl/scala/tools/nsc/interpreter/IMain.scala5
-rw-r--r--src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala6
2 files changed, 5 insertions, 6 deletions
diff --git a/src/repl/scala/tools/nsc/interpreter/IMain.scala b/src/repl/scala/tools/nsc/interpreter/IMain.scala
index b35f71aeef..6d921ed987 100644
--- a/src/repl/scala/tools/nsc/interpreter/IMain.scala
+++ b/src/repl/scala/tools/nsc/interpreter/IMain.scala
@@ -838,8 +838,6 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
def imports = importedSymbols
def value = Some(handlers.last) filter (h => h.definesValue) map (h => definedSymbols(h.definesTerm.get)) getOrElse NoSymbol
- val printResults = IMain.this.printResults
-
val lineRep = new ReadEvalPrint()
private var _originalLine: String = null
@@ -948,7 +946,8 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
}
// compile the result-extraction object
- withoutWarnings(lineRep compile ResultObjectSourceCode(handlers))
+ val handls = if (printResults) handlers else Nil
+ withoutWarnings(lineRep compile ResultObjectSourceCode(handls))
}
}
diff --git a/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala b/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala
index 085a7c6065..c6f0cca481 100644
--- a/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala
+++ b/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala
@@ -107,7 +107,7 @@ trait MemberHandlers {
override def resultExtractionCode(req: Request): String = {
val isInternal = isUserVarName(name) && req.lookupTypeOf(name) == "Unit"
- if (!mods.isPublic || isInternal || !req.printResults) ""
+ if (!mods.isPublic || isInternal) ""
else {
// if this is a lazy val we avoid evaluating it here
val resultString =
@@ -151,11 +151,11 @@ trait MemberHandlers {
"""val %s = %s""".format(name, lhs)
/** Print out lhs instead of the generated varName */
- override def resultExtractionCode(req: Request) = if (req.printResults) {
+ override def resultExtractionCode(req: Request) = {
val lhsType = string2code(req lookupTypeOf name)
val res = string2code(req fullPath name)
""" + "%s: %s = " + %s + "\n" """.format(string2code(lhs.toString), lhsType, res) + "\n"
- } else ""
+ }
}
class ModuleHandler(module: ModuleDef) extends MemberDefHandler(module) {