File tree 1 file changed +4
-6
lines changed
compiler/src/dotty/tools/repl 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 }
5
5
import java .lang .{ ClassLoader , ExceptionInInitializerError }
6
6
import java .lang .reflect .InvocationTargetException
7
7
8
+ import scala .runtime .ScalaRunTime
8
9
9
10
import dotc .core .Contexts .Context
10
11
import dotc .core .Denotations .Denotation
@@ -40,6 +41,8 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
40
41
myClassLoader
41
42
}
42
43
44
+ private [this ] def MaxStringElements = 1000 // no need to mkString billions of elements
45
+
43
46
/** Load the value of the symbol using reflection.
44
47
*
45
48
* Calling this method evaluates the expression using reflection
@@ -52,12 +55,7 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
52
55
resObj
53
56
.getDeclaredMethods.find(_.getName == sym.name.encode.toString)
54
57
.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)
61
59
if (! sym.is(Flags .Method ) && sym.info == defn.UnitType )
62
60
None
63
61
else
You can’t perform that action at this time.
0 commit comments