File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
compiler/src/dotty/tools/repl Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import java.io.{ StringWriter, PrintWriter }
55import java .lang .{ ClassLoader , ExceptionInInitializerError }
66import java .lang .reflect .InvocationTargetException
77
8+ import scala .runtime .ScalaRunTime
89
910import dotc .core .Contexts .Context
1011import dotc .core .Denotations .Denotation
@@ -40,6 +41,8 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
4041 myClassLoader
4142 }
4243
44+ private [this ] def MaxStringElements = 1000 // no need to mkString billions of elements
45+
4346 /** Load the value of the symbol using reflection.
4447 *
4548 * Calling this method evaluates the expression using reflection
@@ -52,12 +55,7 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
5255 resObj
5356 .getDeclaredMethods.find(_.getName == sym.name.encode.toString)
5457 .map(_.invoke(null ))
55- val string = value.map {
56- case null => " null" // Calling .toString on null => NPE
57- case " " => " \"\" " // Special cased for empty string, following scalac
58- case a : Array [_] => a.mkString(" Array(" , " , " , " )" )
59- case x => x.toString
60- }
58+ val string = value.map(ScalaRunTime .replStringOf(_, MaxStringElements ).trim)
6159 if (! sym.is(Flags .Method ) && sym.info == defn.UnitType )
6260 None
6361 else
You can’t perform that action at this time.
0 commit comments