Skip to content

Commit 122d759

Browse files
authored
Merge pull request #7010 from rjolly/master
Fix double execution in JSR223 Implementation
2 parents d3a2d61 + 4daf06d commit 122d759

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class ScalaSettings extends Settings.SettingGroup {
8181
val XshowPhases: Setting[Boolean] = BooleanSetting("-Xshow-phases", "Print all compiler phases")
8282
val XnoValueClasses: Setting[Boolean] = BooleanSetting("-Xno-value-classes", "Do not use value classes. Helps debugging.")
8383
val XreplLineWidth: Setting[Int] = IntSetting("-Xrepl-line-width", "Maximal number of columns per line for REPL output", 390)
84+
val XreplDisableDisplay: Setting[Boolean] = BooleanSetting("-Xrepl-disable-display", "Do not display definitions in REPL.")
8485
val XfatalWarnings: Setting[Boolean] = BooleanSetting("-Xfatal-warnings", "Fail the compilation if there are any warnings.")
8586
val XverifySignatures: Setting[Boolean] = BooleanSetting("-Xverify-signatures", "Verify generic signatures in generated bytecode.")
8687
val XignoreScala2Macros: Setting[Boolean] = BooleanSetting("-Xignore-scala2-macros", "Ignore errors when compiling code that calls Scala2 macros, these will fail at runtime.")

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ class ReplDriver(settings: Array[String],
205205
case _ => // new line, empty tree
206206
state
207207
}
208-
out.println()
208+
implicit val ctx: Context = newState.context
209+
if (!ctx.settings.XreplDisableDisplay.value)
210+
out.println()
209211
newState
210212
}
211213

@@ -238,7 +240,11 @@ class ReplDriver(settings: Array[String],
238240

239241
val warnings = newState.context.reporter.removeBufferedMessages(newState.context)
240242
displayErrors(warnings)(newState) // display warnings
241-
displayDefinitions(unit.tpdTree, newestWrapper)(newStateWithImports)
243+
implicit val ctx = newState.context
244+
if (!ctx.settings.XreplDisableDisplay.value)
245+
displayDefinitions(unit.tpdTree, newestWrapper)(newStateWithImports)
246+
else
247+
newStateWithImports
242248
}
243249
)
244250
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class ScriptEngine extends AbstractScriptEngine {
2121
Array(
2222
"-classpath", "", // Avoid the default "."
2323
"-usejavacp",
24-
"-color:never"
24+
"-color:never",
25+
"-Xrepl-disable-display"
2526
), Console.out, None)
2627
private val rendering = new Rendering
2728
private var state: State = driver.initialState
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
val res0: Int = 42
2-
31
42

tests/run-with-compiler/scripting.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ object Test {
55
println(e.eval("42"))
66
}
77
}
8-

0 commit comments

Comments
 (0)