Skip to content

Commit 1904a78

Browse files
committed
fix test: pass maxElements into myReplStringOf
thanks @prolativ
1 parent 3e21b0b commit 1904a78

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

compiler/src/dotty/tools/repl/Rendering.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
3232

3333
private var myClassLoader: AbstractFileClassLoader = _
3434

35-
private var myReplStringOf: Object => String = _
35+
/** (value, maxElements) => String */
36+
private var myReplStringOf: (Object, Int) => String = _
3637

3738
/** Class loader used to load compiled code */
3839
private[repl] def classLoader()(using Context) =
@@ -64,12 +65,12 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
6465
val meth = scalaRuntime.getMethod(renderer, classOf[Object], classOf[Int], classOf[Boolean])
6566
val truly = java.lang.Boolean.TRUE
6667

67-
(value: Object) => meth.invoke(null, value, Integer.valueOf(maxPrintElements), truly).asInstanceOf[String]
68+
(value: Object, maxElements: Int) => meth.invoke(null, value, maxElements, truly).asInstanceOf[String]
6869
} catch {
6970
case _: NoSuchMethodException =>
7071
val meth = scalaRuntime.getMethod(renderer, classOf[Object], classOf[Int])
7172

72-
(value: Object) => meth.invoke(null, value, Integer.valueOf(maxPrintElements)).asInstanceOf[String]
73+
(value: Object, maxElements: Int) => meth.invoke(null, value, maxElements).asInstanceOf[String]
7374
}
7475
}
7576
myClassLoader
@@ -91,7 +92,8 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
9192
private[repl] def replStringOf(value: Object)(using Context): String =
9293
assert(myReplStringOf != null,
9394
"replStringOf should only be called on values creating using `classLoader()`, but `classLoader()` has not been called so far")
94-
val res = myReplStringOf(value)
95+
val maxPrintElements = ctx.settings.VreplMaxPrintElements.valueIn(ctx.settingsState)
96+
val res = myReplStringOf(value, maxPrintElements)
9597
if res == null then "null // non-null reference has null-valued toString" else truncate(res)
9698

9799
/** Load the value of the symbol using reflection.

0 commit comments

Comments
 (0)