From 4c9372f665660324023ae49edb42ac1e70ed7e79 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 20 Nov 2009 18:08:57 +0000 Subject: 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 ++. --- src/compiler/scala/tools/nsc/util/TreeSet.scala | 14 +++----------- 1 file 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 = { -- cgit v1.2.3