diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2012-05-05 17:52:33 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2012-05-05 17:53:46 +0200 |
commit | a21f14defaedd6ba314261bf78a0d257823c080b (patch) | |
tree | fd8c85a3996c23664f906986fa68487d16198d03 /src/library | |
parent | dd8f53d510ad820d5b34b20f2846c8da5d4942a1 (diff) | |
download | scala-a21f14defaedd6ba314261bf78a0d257823c080b.tar.gz scala-a21f14defaedd6ba314261bf78a0d257823c080b.tar.bz2 scala-a21f14defaedd6ba314261bf78a0d257823c080b.zip |
Don't admit primitive arrays as a generic Java varargs param.
They were sneaking through as polymorphic Arrays and avoiding boxing.
Closes SI-4216
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/runtime/ScalaRunTime.scala | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index 0797b65fb0..4c5e0e408b 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -130,16 +130,18 @@ object ScalaRunTime { case null => throw new NullPointerException } - /** Convert a numeric value array to an object array. + /** Convert an array to an object array. * Needed to deal with vararg arguments of primitive types that are passed * to a generic Java vararg parameter T ... */ - def toObjectArray(src: AnyRef): Array[Object] = { - val length = array_length(src) - val dest = new Array[Object](length) - for (i <- 0 until length) - array_update(dest, i, array_apply(src, i)) - dest + def toObjectArray(src: AnyRef): Array[Object] = src match { + case x: Array[AnyRef] => x + case _ => + val length = array_length(src) + val dest = new Array[Object](length) + for (i <- 0 until length) + array_update(dest, i, array_apply(src, i)) + dest } def toArray[T](xs: collection.Seq[T]) = { |