From 2c16790ae48debe6e8b07b7ece86b0c665359cfd Mon Sep 17 00:00:00 2001 From: Rex Kerr Date: Sun, 30 Aug 2015 17:27:05 -0700 Subject: SI-9379 Added toString to .zipped to allow Stream etc to short-circuit Tuple2Zipped and Tuple3Zipped would try to compute a hash code when .toString was called on them. This overrides toString to print (collection1, collection2).zipped instead, using the collection's own toString method. This allows collections that have a toString but not a hashCode (such as Iterator.from(0) and s = 1 #:: s) to print out as they usually do. JUnit test to verify the deferral to collections' .toString. --- src/library/scala/runtime/Tuple2Zipped.scala | 2 ++ src/library/scala/runtime/Tuple3Zipped.scala | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src/library') diff --git a/src/library/scala/runtime/Tuple2Zipped.scala b/src/library/scala/runtime/Tuple2Zipped.scala index 512c4fbc27..1c432b0403 100644 --- a/src/library/scala/runtime/Tuple2Zipped.scala +++ b/src/library/scala/runtime/Tuple2Zipped.scala @@ -110,6 +110,8 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1 return } } + + override def toString = "(%s, %s).zipped".format(colls._1.toString, colls._2.toString) } object Tuple2Zipped { diff --git a/src/library/scala/runtime/Tuple3Zipped.scala b/src/library/scala/runtime/Tuple3Zipped.scala index ffd44acf81..3bab86921b 100644 --- a/src/library/scala/runtime/Tuple3Zipped.scala +++ b/src/library/scala/runtime/Tuple3Zipped.scala @@ -118,6 +118,8 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers return } } + + override def toString: String = "(%s, %s, %s).zipped".format(colls._1.toString, colls._2.toString, colls._3.toString) } object Tuple3Zipped { -- cgit v1.2.3