Skip to content

Commit f481be9

Browse files
author
Christopher Marshall
committed
Fixes Issue #337 by making builder expression non-strict
- See #337 -
1 parent 7872b6a commit f481be9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compat/src/main/scala-2.11_2.12/scala/collection/compat/PackageShared.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ private[compat] trait PackageShared {
5555

5656
implicit def genericCompanionToCBF[A, CC[X] <: GenTraversable[X]](
5757
fact: GenericCompanion[CC]): CanBuildFrom[Any, A, CC[A]] = {
58-
val builder: m.Builder[A, CC[A]] = fact match {
58+
/* see https://github.com/scala/scala-library-compat/issues/337
59+
`simpleCBF.apply` takes a by-name parameter and relies on
60+
repeated references generating new builders, thus this expression
61+
must be non-strict
62+
*/
63+
def builder: m.Builder[A, CC[A]] = fact match {
5964
case c.Seq | i.Seq => new IdentityPreservingBuilder[A, i.Seq](i.Seq.newBuilder[A])
6065
case c.LinearSeq | i.LinearSeq =>
6166
new IdentityPreservingBuilder[A, i.LinearSeq](i.LinearSeq.newBuilder[A])

0 commit comments

Comments
 (0)