diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index c52f7a231896..874c22e7728b 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -81,6 +81,7 @@ class ScalaSettings extends Settings.SettingGroup { val Xprompt: Setting[Boolean] = BooleanSetting("-Xprompt", "Display a prompt after each error (debugging option).") val XnoValueClasses: Setting[Boolean] = BooleanSetting("-Xno-value-classes", "Do not use value classes. Helps debugging.") val XreplLineWidth: Setting[Int] = IntSetting("-Xrepl-line-width", "Maximal number of columns per line for REPL output", 390) + val XreplDisableDisplay: Setting[Boolean] = BooleanSetting("-Xrepl-disable-display", "Do not display definitions in REPL.") val XfatalWarnings: Setting[Boolean] = BooleanSetting("-Xfatal-warnings", "Fail the compilation if there are any warnings.") val XverifySignatures: Setting[Boolean] = BooleanSetting("-Xverify-signatures", "Verify generic signatures in generated bytecode.") val XignoreScala2Macros: Setting[Boolean] = BooleanSetting("-Xignore-scala2-macros", "Ignore errors when compiling code that calls Scala2 macros, these will fail at runtime.") diff --git a/compiler/src/dotty/tools/repl/ReplDriver.scala b/compiler/src/dotty/tools/repl/ReplDriver.scala index acfa33f02765..b3a9c56590bd 100644 --- a/compiler/src/dotty/tools/repl/ReplDriver.scala +++ b/compiler/src/dotty/tools/repl/ReplDriver.scala @@ -205,7 +205,9 @@ class ReplDriver(settings: Array[String], case _ => // new line, empty tree state } - out.println() + implicit val ctx: Context = newState.context + if (!ctx.settings.XreplDisableDisplay.value) + out.println() newState } @@ -238,7 +240,11 @@ class ReplDriver(settings: Array[String], val warnings = newState.context.reporter.removeBufferedMessages(newState.context) displayErrors(warnings)(newState) // display warnings - displayDefinitions(unit.tpdTree, newestWrapper)(newStateWithImports) + implicit val ctx = newState.context + if (!ctx.settings.XreplDisableDisplay.value) + displayDefinitions(unit.tpdTree, newestWrapper)(newStateWithImports) + else + newStateWithImports } ) } diff --git a/compiler/src/dotty/tools/repl/ScriptEngine.scala b/compiler/src/dotty/tools/repl/ScriptEngine.scala index a1b26412f2d3..7a03fa3eab8e 100644 --- a/compiler/src/dotty/tools/repl/ScriptEngine.scala +++ b/compiler/src/dotty/tools/repl/ScriptEngine.scala @@ -21,7 +21,8 @@ class ScriptEngine extends AbstractScriptEngine { Array( "-classpath", "", // Avoid the default "." "-usejavacp", - "-color:never" + "-color:never", + "-Xrepl-disable-display" ), Console.out, None) private val rendering = new Rendering private var state: State = driver.initialState diff --git a/tests/run-with-compiler/scripting.check b/tests/run-with-compiler/scripting.check index 2585ccd6c17d..d81cc0710eb6 100644 --- a/tests/run-with-compiler/scripting.check +++ b/tests/run-with-compiler/scripting.check @@ -1,3 +1 @@ -val res0: Int = 42 - 42 diff --git a/tests/run-with-compiler/scripting.scala b/tests/run-with-compiler/scripting.scala index 2eb209201a0c..4b5807b29385 100644 --- a/tests/run-with-compiler/scripting.scala +++ b/tests/run-with-compiler/scripting.scala @@ -5,4 +5,3 @@ object Test { println(e.eval("42")) } } -