File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
main/scala-2.11_2.12/scala/collection/compat/immutable
test/scala/test/scala/collection Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -365,7 +365,7 @@ final class LazyList[+A] private (private[this] var lazyState: () => LazyList.St
365
365
newLL {
366
366
if (isEmpty) suffix match {
367
367
case lazyList : LazyList [B ] => lazyList.state // don't recompute the LazyList
368
- case _ => stateFromIterator(suffix .toIterator)
368
+ case coll => stateFromIterator(coll .toIterator)
369
369
} else sCons(head, tail lazyAppendedAll suffix)
370
370
}
371
371
Original file line number Diff line number Diff line change @@ -376,4 +376,12 @@ class LazyListTest {
376
376
assertNoStackOverflow((new L ).a)
377
377
assertNoStackOverflow((new L ).b)
378
378
}
379
+
380
+ // scala/bug#11931
381
+ @ Test
382
+ def lazyAppendedAllExecutesOnce (): Unit = {
383
+ var count = 0
384
+ LazyList (1 ).lazyAppendedAll({ count += 1 ; Seq (2 )}).toList
385
+ assertEquals(1 , count)
386
+ }
379
387
}
You can’t perform that action at this time.
0 commit comments