File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
main/scala/scala/util/parsing/input
test/scala/scala/util/parsing/input Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -243,7 +243,12 @@ private class Page[T: ClassTag](val num: Int) {
243243 /** The last page as currently present in the sequence; This can change as more
244244 * elements get appended to the sequence. */
245245 final def latest : Page [T ] = {
246- if (later.next != null ) later = later.next.latest
246+ var oldLater = later
247+ while (later.next != null ) later = later.next
248+ while (oldLater.next != null ) {
249+ oldLater = oldLater.next
250+ oldLater.later = later
251+ }
247252 later
248253 }
249254
Original file line number Diff line number Diff line change 1+ package scala .util .parsing .input
2+
3+ import org .junit .Assert ._
4+ import org .junit .Test
5+
6+ class gh64 {
7+
8+ @ Test
9+ def test : Unit = {
10+ val len = 4096 * 20000
11+ val i = Iterator .fill(len)(true ) // use `true` to make this test more lightweight
12+ val pagedSeq = PagedSeq .fromIterator(i)
13+ pagedSeq.slice(len - 1 ) // load the whole pagedSeq without caching `latest` element
14+ assertEquals(len, pagedSeq.length) // should not throw StackOverflowError
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments