Get rid of structural type in Iterator.scala
Implementation of Iterator.scala defined a structural type by mistake. By naming a class we get rid of that structural type. Fixes #4791. No review. git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@25283 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
f9ce00fcc4
commit
c30f0bf306
|
@ -507,7 +507,14 @@ trait Iterator[+A] extends TraversableOnce[A] {
|
||||||
*/
|
*/
|
||||||
def span(p: A => Boolean): (Iterator[A], Iterator[A]) = {
|
def span(p: A => Boolean): (Iterator[A], Iterator[A]) = {
|
||||||
val self = buffered
|
val self = buffered
|
||||||
val leading = new Iterator[A] {
|
|
||||||
|
/**
|
||||||
|
* Giving a name to following iterator (as opposed to trailing) because
|
||||||
|
* anonymous class is represented as a structural type that trailing
|
||||||
|
* iterator is referring (the finish() method) and thus triggering
|
||||||
|
* handling of structural calls. It's not what's intended here.
|
||||||
|
*/
|
||||||
|
class Leading extends Iterator[A] {
|
||||||
private var isDone = false
|
private var isDone = false
|
||||||
val lookahead = new mutable.Queue[A]
|
val lookahead = new mutable.Queue[A]
|
||||||
def advance() = {
|
def advance() = {
|
||||||
|
@ -528,6 +535,7 @@ trait Iterator[+A] extends TraversableOnce[A] {
|
||||||
lookahead.dequeue()
|
lookahead.dequeue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val leading = new Leading
|
||||||
val trailing = new Iterator[A] {
|
val trailing = new Iterator[A] {
|
||||||
private lazy val it = {
|
private lazy val it = {
|
||||||
leading.finish()
|
leading.finish()
|
||||||
|
|
Loading…
Reference in New Issue