diff options
author | Ichoran <ichoran@gmail.com> | 2015-01-30 14:54:51 -0800 |
---|---|---|
committer | Ichoran <ichoran@gmail.com> | 2015-01-30 14:54:51 -0800 |
commit | 5d7098c629bbb7cc0ab7e74c235bd4afca3de24e (patch) | |
tree | 4a43c8211e49010f89af14bbb968e964f32d7767 | |
parent | 41a5f4517e981144c7f72fff1d465ab034b8196d (diff) | |
parent | fb043761806f8ef2c7a662f15ba5ac5731426dbf (diff) | |
download | scala-5d7098c629bbb7cc0ab7e74c235bd4afca3de24e.tar.gz scala-5d7098c629bbb7cc0ab7e74c235bd4afca3de24e.tar.bz2 scala-5d7098c629bbb7cc0ab7e74c235bd4afca3de24e.zip |
Merge pull request #4259 from mzitnik/2.11.x
SI-9072 Vector ++ concatenation of parallel collection cause inconsisten...
-rw-r--r-- | src/library/scala/collection/immutable/Vector.scala | 2 | ||||
-rw-r--r-- | test/junit/scala/collection/immutable/VectorTest.scala | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala index c7da447f72..47a623a616 100644 --- a/src/library/scala/collection/immutable/Vector.scala +++ b/src/library/scala/collection/immutable/Vector.scala @@ -215,7 +215,7 @@ override def companion: GenericCompanion[Vector] = Vector import Vector.{Log2ConcatFaster, TinyAppendFaster} if (that.isEmpty) this.asInstanceOf[That] else { - val again = if (!that.isTraversableAgain) that.toVector else that + val again = if (!that.isTraversableAgain) that.toVector else that.seq again.size match { // Often it's better to append small numbers of elements (or prepend if RHS is a vector) case n if n <= TinyAppendFaster || n < (this.size >> Log2ConcatFaster) => diff --git a/test/junit/scala/collection/immutable/VectorTest.scala b/test/junit/scala/collection/immutable/VectorTest.scala new file mode 100644 index 0000000000..e7edba3e43 --- /dev/null +++ b/test/junit/scala/collection/immutable/VectorTest.scala @@ -0,0 +1,20 @@ +package scala.collection.immutable + +import org.junit.{Assert, Test} +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +@RunWith(classOf[JUnit4]) +class VectorTest { + /** + * Test Vector ++ with a small parallel collection concatenation (SI-9072). + * + */ + @Test + def testPlusPlus(): Unit = { + val smallVec = (0 to 1) + val smallParVec = smallVec.par + val testElementsSize = (0 to 1000).map( _ => Vector.empty ++ smallParVec ) + Assert.assertTrue(testElementsSize.forall( v => v.size == 2 )) + } +} |