summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-05-12 23:37:48 +0000
committerPaul Phillips <paulp@improving.org>2010-05-12 23:37:48 +0000
commit7c7c267d4e1efa2c85017751b448b31cf7e2a5b1 (patch)
treed5f04bb9410d35a8b8660f9cc38aed157c74a7b9 /src
parentfd5d20d2cf2dbe2e8c66b5d43167cd6fbc90220e (diff)
downloadscala-7c7c267d4e1efa2c85017751b448b31cf7e2a5b1.tar.gz
scala-7c7c267d4e1efa2c85017751b448b31cf7e2a5b1.tar.bz2
scala-7c7c267d4e1efa2c85017751b448b31cf7e2a5b1.zip
Fixed a long standing issue with interpreter co...
Fixed a long standing issue with interpreter commands containing more than a single statement. It was the classic "reversing a list and then flattening it is not the same as flattening and then reversing it." Closes #3116, no review.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala
index 749ee7bce9..70d416e19e 100644
--- a/src/compiler/scala/tools/nsc/Interpreter.scala
+++ b/src/compiler/scala/tools/nsc/Interpreter.scala
@@ -236,6 +236,7 @@ class Interpreter(val settings: Settings, out: PrintWriter) {
private val usedNameMap = new HashMap[Name, Request]()
private val boundNameMap = new HashMap[Name, Request]()
private def allHandlers = prevRequests.toList flatMap (_.handlers)
+ private def allReqAndHandlers = prevRequests.toList flatMap (req => req.handlers map (req -> _))
def printAllTypeOf = {
prevRequests foreach { req =>
@@ -418,10 +419,7 @@ class Interpreter(val settings: Settings, out: PrintWriter) {
}
/** Flatten the handlers out and pair each with the original request */
- val rhpairs = prevRequests.reverse.toList flatMap { req =>
- req.handlers map (ReqAndHandler(req, _))
- }
- select(rhpairs, wanted).reverse
+ select(allReqAndHandlers map { case (r, h) => ReqAndHandler(r, h) }, wanted)
}
val code, trailingBraces, accessPath = new StringBuffer
@@ -682,7 +680,7 @@ class Interpreter(val settings: Settings, out: PrintWriter) {
def extraCodeToEvaluate(req: Request, code: PrintWriter) { }
def resultExtractionCode(req: Request, code: PrintWriter) { }
- override def toString = "%s(usedNames = %s)".format(this.getClass, usedNames)
+ override def toString = "%s(used = %s)".format(this.getClass.toString split '.' last, usedNames)
}
private class GenericHandler(member: Tree) extends MemberHandler(member)
@@ -985,6 +983,8 @@ class Interpreter(val settings: Settings, out: PrintWriter) {
}
}
}
+
+ override def toString = "Request(line=%s, %s trees)".format(line, trees.size)
}
/** A container class for methods to be injected into the repl