diff options
author | Paul Phillips <paulp@improving.org> | 2011-05-06 04:32:18 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-05-06 04:32:18 +0000 |
commit | 14cd653295b5ed3f10b82193a9fb6da0867e31d6 (patch) | |
tree | 3ea36ac2e0c982aaef0f598aa8676a53c158e213 | |
parent | 57a00a46c823663238a7af1cd27b1cf80cc81168 (diff) | |
download | scala-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.
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/Trees.scala | 3 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 2 | ||||
-rw-r--r-- | src/library/scala/runtime/ScalaRunTime.scala | 11 |
3 files changed, 14 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 56a7ee6ec8..0e15979460 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -295,6 +295,9 @@ trait Trees extends reflect.generic.Trees { self: SymbolTable => (superRef /: argss) (Apply) } + def Apply(sym: Symbol, args: Tree*): Tree = + Apply(Ident(sym), args.toList) + def Super(sym: Symbol, mix: TypeName): Tree = Super(This(sym), mix) def This(sym: Symbol): Tree = This(sym.name.toTypeName) setSymbol sym diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 007ab36e5e..3f509eae65 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -569,7 +569,7 @@ abstract class Erasure extends AddInterfaces else BLOCK(tree, UNIT) case x => assert(x != ArrayClass) - (REF(unboxMethod(pt.typeSymbol)) APPLY tree) setType pt + Apply(unboxMethod(pt.typeSymbol), tree) setType pt }) } 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 + "(", ", ", ")") |