Skip to content

Commit 7db844f

Browse files
dwijnandSethTisue
andcommitted
REPL: display the compiler + Java version on startup
Co-authored-by: Seth Tisue <seth@tisue.net>
1 parent c53cc91 commit 7db844f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class JLineTerminal extends java.io.Closeable {
2828
private def blue(str: String)(using Context) =
2929
if (ctx.settings.color.value != "never") Console.BLUE + str + Console.RESET
3030
else str
31-
private def prompt(using Context) = blue("scala> ")
31+
private def prompt(using Context) = blue("\nscala> ")
3232
private def newLinePrompt(using Context) = blue(" | ")
3333

3434
/** Blockingly read line from `System.in`

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import java.nio.charset.StandardCharsets
55

66
import dotty.tools.dotc.ast.Trees._
77
import dotty.tools.dotc.ast.{tpd, untpd}
8+
import dotty.tools.dotc.config.Properties.{javaVersion, javaVmName, simpleVersionString}
89
import dotty.tools.dotc.core.Contexts._
910
import dotty.tools.dotc.core.Phases.{unfusedPhases, typerPhase}
1011
import dotty.tools.dotc.core.Denotations.Denotation
@@ -124,6 +125,10 @@ class ReplDriver(settings: Array[String],
124125
final def runUntilQuit(initialState: State = initialState): State = {
125126
val terminal = new JLineTerminal
126127

128+
out.println(
129+
s"""Welcome to Scala $simpleVersionString ($javaVersion, Java $javaVmName).
130+
|Type in expressions for evaluation. Or try :help.""".stripMargin)
131+
127132
/** Blockingly read a line, getting back a parse result */
128133
def readLine(state: State): ParseResult = {
129134
val completer: Completer = { (_, line, candidates) =>
@@ -208,7 +213,7 @@ class ReplDriver(settings: Array[String],
208213
}
209214

210215
private def interpret(res: ParseResult)(implicit state: State): State = {
211-
val newState = res match {
216+
res match {
212217
case parsed: Parsed if parsed.trees.nonEmpty =>
213218
compile(parsed, state)
214219

@@ -225,11 +230,6 @@ class ReplDriver(settings: Array[String],
225230
case _ => // new line, empty tree
226231
state
227232
}
228-
inContext(newState.context) {
229-
if (!ctx.settings.XreplDisableDisplay.value)
230-
out.println()
231-
newState
232-
}
233233
}
234234

235235
/** Compile `parsed` trees and evolve `state` in accordance */

0 commit comments

Comments
 (0)