Skip to content

Commit 511caeb

Browse files
committed
Fix printing of lazy vals in the REPL
1 parent 5994bfa commit 511caeb

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

compiler/src/dotty/tools/dotc/printing/ReplPrinter.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ReplPrinter(_ctx: Context) extends DecompilerPrinter(_ctx) {
2929
else Str(const.value.toString)
3030

3131
override def dclText(sym: Symbol): Text = {
32+
("lazy": Text).provided(sym.is(Lazy)) ~~
3233
toText(sym) ~ {
3334
if (sym.is(Method)) toText(sym.info)
3435
else if (sym.isType && sym.info.isTypeAlias) toText(sym.info)

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,8 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
7676
val dcl = d.symbol.showUser
7777

7878
try {
79-
val resultValue =
80-
if (d.symbol.is(Flags.Lazy)) Some("<lazy>")
81-
else valueOf(d.symbol)
82-
83-
resultValue.map(value => s"$dcl = $value")
79+
if (d.symbol.is(Flags.Lazy)) Some(dcl)
80+
else valueOf(d.symbol).map(value => s"$dcl = $value")
8481
}
8582
catch { case ex: InvocationTargetException => Some(renderError(ex)) }
8683
}

compiler/test-resources/repl/i5350

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ scala> foo
44
Hello
55
scala> { lazy val bar: Unit = { println("Hello") }; bar }
66
Hello
7-
val bar: Unit = <lazy>
7+
lazy val bar: Unit

0 commit comments

Comments
 (0)