summaryrefslogtreecommitdiff
path: root/src/library/scala/runtime/ScalaRunTime.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-05-06 04:32:18 +0000
committerPaul Phillips <paulp@improving.org>2011-05-06 04:32:18 +0000
commit14cd653295b5ed3f10b82193a9fb6da0867e31d6 (patch)
tree3ea36ac2e0c982aaef0f598aa8676a53c158e213 /src/library/scala/runtime/ScalaRunTime.scala
parent57a00a46c823663238a7af1cd27b1cf80cc81168 (diff)
downloadscala-14cd653295b5ed3f10b82193a9fb6da0867e31d6.tar.gz
scala-14cd653295b5ed3f10b82193a9fb6da0867e31d6.tar.bz2
scala-14cd653295b5ed3f10b82193a9fb6da0867e31d6.zip
Special case Array[Unit] printing in the repl t...
Special case Array[Unit] printing in the repl to make soc happy. There are still nulls in there, but now we can blissfully pretend they don't exist, until we crash. Closes #4510, no review.
Diffstat (limited to 'src/library/scala/runtime/ScalaRunTime.scala')
-rw-r--r--src/library/scala/runtime/ScalaRunTime.scala11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala
index 41a63777c5..7a8224298b 100644
--- a/src/library/scala/runtime/ScalaRunTime.scala
+++ b/src/library/scala/runtime/ScalaRunTime.scala
@@ -287,6 +287,15 @@ object ScalaRunTime {
case (k, v) => inner(k) + " -> " + inner(v)
case _ => inner(arg)
}
+
+ // Special casing Unit arrays, the value class which uses a reference array type.
+ def arrayToString(x: AnyRef) = {
+ if (x.getClass.getComponentType == classOf[BoxedUnit])
+ 0 until (array_length(x) min maxElements) map (_ => "()") mkString ("Array(", ", ", ")")
+ else
+ WrappedArray make x take maxElements map inner mkString ("Array(", ", ", ")")
+ }
+
// The recursively applied attempt to prettify Array printing.
// Note that iterator is used if possible and foreach is used as a
// last resort, because the parallel collections "foreach" in a
@@ -296,7 +305,7 @@ object ScalaRunTime {
case "" => "\"\""
case x: String => if (x.head.isWhitespace || x.last.isWhitespace) "\"" + x + "\"" else x
case x if useOwnToString(x) => x toString
- case x: AnyRef if isArray(x) => WrappedArray make x take maxElements map inner mkString ("Array(", ", ", ")")
+ case x: AnyRef if isArray(x) => arrayToString(x)
case x: collection.Map[_, _] => x.iterator take maxElements map mapInner mkString (x.stringPrefix + "(", ", ", ")")
case x: Iterable[_] => x.iterator take maxElements map inner mkString (x.stringPrefix + "(", ", ", ")")
case x: Traversable[_] => x take maxElements map inner mkString (x.stringPrefix + "(", ", ", ")")