summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-03-24 12:18:08 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-03-24 12:18:08 +1000
commit7741d3f0a37bb673462863ba389c27ce6eccaccf (patch)
treeab1769861fba7135366b5484b8824fa7c812ff8b /src
parenteb05bea0f768d237946d1862b33817ed93661952 (diff)
parent8e0a386508d6cb655db0a29a23fb26170b262548 (diff)
downloadscala-7741d3f0a37bb673462863ba389c27ce6eccaccf.tar.gz
scala-7741d3f0a37bb673462863ba389c27ce6eccaccf.tar.bz2
scala-7741d3f0a37bb673462863ba389c27ce6eccaccf.zip
Merge pull request #4381 from khernyo/issue/9219
SI-9219 Stream toString returns unexpected result
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/collection/immutable/Stream.scala21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala
index 9ed5162061..f303e79bb3 100644
--- a/src/library/scala/collection/immutable/Stream.scala
+++ b/src/library/scala/collection/immutable/Stream.scala
@@ -743,16 +743,18 @@ self =>
b append end
return b
}
- if ((cursor ne scout) && scout.tailDefined) {
+ if (cursor ne scout) {
cursor = scout
- scout = scout.tail
- // Use 2x 1x iterator trick for cycle detection; slow iterator can add strings
- while ((cursor ne scout) && scout.tailDefined) {
- b append sep append cursor.head
- n += 1
- cursor = cursor.tail
+ if (scout.tailDefined) {
scout = scout.tail
- if (scout.tailDefined) scout = scout.tail
+ // Use 2x 1x iterator trick for cycle detection; slow iterator can add strings
+ while ((cursor ne scout) && scout.tailDefined) {
+ b append sep append cursor.head
+ n += 1
+ cursor = cursor.tail
+ scout = scout.tail
+ if (scout.tailDefined) scout = scout.tail
+ }
}
}
if (!scout.tailDefined) { // Not a cycle, scout hit an end
@@ -761,6 +763,9 @@ self =>
n += 1
cursor = cursor.tail
}
+ if (cursor.nonEmpty) {
+ b append sep append cursor.head
+ }
}
else {
// Cycle.