summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-08-18 06:16:15 +0000
committerPaul Phillips <paulp@improving.org>2009-08-18 06:16:15 +0000
commitad8d6f6753a762472cae364d197c108e0166b48b (patch)
tree2727e5f3fa5a1574fdb22e8a28ef3cbcca7e270b
parent420311df8d3408c0ed719fec12045fa41e8241ef (diff)
downloadscala-ad8d6f6753a762472cae364d197c108e0166b48b.tar.gz
scala-ad8d6f6753a762472cae364d197c108e0166b48b.tar.bz2
scala-ad8d6f6753a762472cae364d197c108e0166b48b.zip
Fix for #2164.
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala
index e257d66a0c..2163c39fd9 100644
--- a/src/compiler/scala/tools/nsc/Interpreter.scala
+++ b/src/compiler/scala/tools/nsc/Interpreter.scala
@@ -168,7 +168,13 @@ class Interpreter(val settings: Settings, out: PrintWriter)
/** Generates names pre0, pre1, etc. via calls to apply method */
class NameCreator(pre: String) {
private var x = -1
- def apply(): String = { x += 1 ; pre + x.toString }
+ def apply(): String = {
+ x += 1
+ val name = pre + x.toString
+ // make sure we don't overwrite their unwisely named res3 etc.
+ if (allBoundNames exists (_.toString == name)) apply()
+ else name
+ }
def reset(): Unit = x = -1
def didGenerate(name: String) =
(name startsWith pre) && ((name drop pre.length) forall (_.isDigit))