Skip to content

Commit 582f151

Browse files
committed
Fix #1369 Print a newline for Unit values
Keeping only one newline for Unit values if there are more of them, in a command.
1 parent 6472ae3 commit 582f151

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ private[repl] class Rendering(compiler: ReplCompiler,
7070
d.symbol.showUser
7171

7272
/** Render value definition result */
73-
def renderVal(d: Denotation)(implicit ctx: Context): Option[String] = {
73+
def renderVal(d: Denotation)(implicit ctx: Context): String = {
7474
val dcl = d.symbol.showUser
7575

7676
try {
7777
val resultValue =
7878
if (d.symbol.is(Flags.Lazy)) Some("<lazy>")
7979
else valueOf(d.symbol)
8080

81-
resultValue.map(value => s"$dcl = $value")
81+
resultValue.fold("")(value => s"$dcl = $value")
8282
}
83-
catch { case ex: InvocationTargetException => Some(renderError(ex)) }
83+
catch { case ex: InvocationTargetException => renderError(ex) }
8484
}
8585

8686
/** Render the stack trace of the underlying exception */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class ReplDriver(settings: Array[String],
272272
(
273273
typeAliases.map("// defined alias " + _.symbol.showUser) ++
274274
defs.map(rendering.renderMethod) ++
275-
vals.map(rendering.renderVal).flatten
275+
vals.map(rendering.renderVal).distinct
276276
).foreach(str => out.println(SyntaxHighlighting(str)))
277277

278278
state.copy(valIndex = state.valIndex - vals.filter(resAndUnit).length)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
scala>()
2+
3+
scala>(); (); ()
4+

0 commit comments

Comments
 (0)