Skip to content

Commit 8d5c465

Browse files
authored
Merge pull request #9117 from december32/fix-#9102-by-name-param-printing
Fix #9102: printing of by-name params in the repl
2 parents f49b95f + 5b17d7b commit 8d5c465

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
222222
case _ => super.toText(tp)
223223
}
224224
else super.toText(tp)
225-
case tp: ExprType =>
226-
exprToText(tp)
227225
case ErasedValueType(tycon, underlying) =>
228226
"ErasedValueType(" ~ toText(tycon) ~ ", " ~ toText(underlying) ~ ")"
229227
case tp: ClassInfo =>

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ class ReplPrinter(_ctx: Context) extends DecompilerPrinter(_ctx) {
1919
if (name.isReplAssignName) name.decode.toString.takeWhile(_ != '$')
2020
else super.nameString(name)
2121

22-
override protected def exprToText(tp: ExprType): Text =
23-
if (debugPrint) super.exprToText(tp)
24-
else ": " ~ toText(tp.resType)
25-
2622
override def toText(sym: Symbol): Text =
2723
if (sym.name.isReplAssignName) nameString(sym.name)
2824
else if (debugPrint) super.toText(sym)
@@ -38,7 +34,12 @@ class ReplPrinter(_ctx: Context) extends DecompilerPrinter(_ctx) {
3834
override def dclText(sym: Symbol): Text = if (debugPrint) super.dclText(sym) else
3935
("lazy": Text).provided(sym.is(Lazy)) ~~
4036
toText(sym) ~ {
41-
if (sym.is(Method)) toText(sym.info)
37+
if (sym.is(Method)) {
38+
sym.info match {
39+
case tp: ExprType => ":" ~~ toText(tp.resType)
40+
case _ => toText(sym.info)
41+
}
42+
}
4243
else if (sym.isType && sym.info.isTypeAlias) toText(sym.info)
4344
else if (sym.isType || sym.isClass) ""
4445
else ":" ~~ toText(sym.info)

compiler/test-resources/repl/i9102

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
scala> def foo(x: => Int) = x.toString
2+
def foo(x: => Int): String
3+
scala> def bar: (=> Int) => String = x => x.toString
4+
def bar: (=> Int) => String
5+
scala> def baz: (Int => String) = x => x.toString
6+
def baz: Int => String
7+
scala> lazy val qux: ((=> Int) => String) = x => x.toString
8+
lazy val qux: (=> Int) => String

0 commit comments

Comments
 (0)