summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-11-20 18:08:57 +0000
committerPaul Phillips <paulp@improving.org>2009-11-20 18:08:57 +0000
commit4c9372f665660324023ae49edb42ac1e70ed7e79 (patch)
tree88aedfbf5cd684482732f4528ab126cb63cafd72
parentd354fa17e79158cf375881a2701254122a43f07b (diff)
downloadscala-4c9372f665660324023ae49edb42ac1e70ed7e79.tar.gz
scala-4c9372f665660324023ae49edb42ac1e70ed7e79.tar.bz2
scala-4c9372f665660324023ae49edb42ac1e70ed7e79.zip
Subtly altered implementation of iterator which...
Subtly altered implementation of iterator which does not go into an infinite loop when deprecated "append" is replaced with ++.
-rw-r--r--src/compiler/scala/tools/nsc/util/TreeSet.scala14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/util/TreeSet.scala b/src/compiler/scala/tools/nsc/util/TreeSet.scala
index 4a84517eb1..059ffd26e4 100644
--- a/src/compiler/scala/tools/nsc/util/TreeSet.scala
+++ b/src/compiler/scala/tools/nsc/util/TreeSet.scala
@@ -43,18 +43,10 @@ class TreeSet[T >: Null <: AnyRef](less: (T, T) => Boolean) extends Set[T] {
def iterator = {
def elems(t: Tree): Iterator[T] = {
- var it = Iterator single t.elem
- // XXX cannot replace these with ++ as the deprecation message says,
- // else after locker builds it fails to build quick with stack overflow:
- // [scalacfork] at scala.collection.Iterator$$anon$6.cur(Iterator.scala:321)
- // [scalacfork] at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:322)
- // [scalacfork] at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:322)
- // [scalacfork] at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:322)
- if (t.l ne null) it = elems(t.l) append it
- if (t.r ne null) it = it append elems(t.r)
- it
+ if (t eq null) Iterator.empty
+ else elems(t.l) ++ (Iterator single t.elem) ++ elems(t.r)
}
- if (tree eq null) Iterator.empty else elems(tree)
+ elems(tree)
}
override def toString(): String = {