We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 5b4a71e + f84acc9 commit ca85886Copy full SHA for ca85886
src/library/scala/collection/immutable/Stream.scala
@@ -1108,11 +1108,15 @@ object Stream extends SeqFactory[Stream] {
1108
override def isEmpty = false
1109
override def head = hd
1110
@volatile private[this] var tlVal: Stream[A] = _
1111
- def tailDefined: Boolean = tlVal ne null
+ @volatile private[this] var tlGen = tl _
1112
+ def tailDefined: Boolean = tlGen eq null
1113
override def tail: Stream[A] = {
1114
if (!tailDefined)
1115
synchronized {
- if (!tailDefined) tlVal = tl
1116
+ if (!tailDefined) {
1117
+ tlVal = tlGen()
1118
+ tlGen = null
1119
+ }
1120
}
1121
1122
tlVal
0 commit comments