Skip to content

Commit c30f0bf

Browse files
author
grek
committed
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
1 parent f9ce00f commit c30f0bf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/library/scala/collection/Iterator.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,14 @@ trait Iterator[+A] extends TraversableOnce[A] {
507507
*/
508508
def span(p: A => Boolean): (Iterator[A], Iterator[A]) = {
509509
val self = buffered
510-
val leading = new Iterator[A] {
510+
511+
/**
512+
* Giving a name to following iterator (as opposed to trailing) because
513+
* anonymous class is represented as a structural type that trailing
514+
* iterator is referring (the finish() method) and thus triggering
515+
* handling of structural calls. It's not what's intended here.
516+
*/
517+
class Leading extends Iterator[A] {
511518
private var isDone = false
512519
val lookahead = new mutable.Queue[A]
513520
def advance() = {
@@ -528,6 +535,7 @@ trait Iterator[+A] extends TraversableOnce[A] {
528535
lookahead.dequeue()
529536
}
530537
}
538+
val leading = new Leading
531539
val trailing = new Iterator[A] {
532540
private lazy val it = {
533541
leading.finish()

0 commit comments

Comments
 (0)