Iterator on IndexedSeqLike fails being an iterator

The following code doesn’t work with Iterator semantics

val a = 1.to(10).toIterator
println(a.take(10).toList)
println(a.take(10).toList)

The general expectation on any iterator is that first one should give 10 items but the next one should be empty. The List’s toIterator works as expected though

val a = 1.to(10).toList.toIterator
println(a.take(10).toList)
println(a.take(10).toList)

Apparently the bug is because overriding the take and drop in the Elements in here https://github.com/scala/scala/blob/2.12.x/src/library/scala/collection/IndexedSeqLike.scala

We either should not implement Iterator for Elements or not override take/drop/slice in it.

Or is it intentionally behaving that way?

I did some poking around and it turns out this is actually undefined behavior. From the doc for take:

Reuse: After calling this method, one should discard the iterator it was called on, and use only the iterator that was returned. Using the old iterator is undefined, subject to change, and may result in changes to the new iterator as well.

See discussion in 3444.