Skip to content

Fix #9102: printing of by-name params in the repl #9117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
case _ => super.toText(tp)
}
else super.toText(tp)
case tp: ExprType =>
exprToText(tp)
case ErasedValueType(tycon, underlying) =>
"ErasedValueType(" ~ toText(tycon) ~ ", " ~ toText(underlying) ~ ")"
case tp: ClassInfo =>
Expand Down
11 changes: 6 additions & 5 deletions compiler/src/dotty/tools/dotc/printing/ReplPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ class ReplPrinter(_ctx: Context) extends DecompilerPrinter(_ctx) {
if (name.isReplAssignName) name.decode.toString.takeWhile(_ != '$')
else super.nameString(name)

override protected def exprToText(tp: ExprType): Text =
if (debugPrint) super.exprToText(tp)
else ": " ~ toText(tp.resType)

override def toText(sym: Symbol): Text =
if (sym.name.isReplAssignName) nameString(sym.name)
else if (debugPrint) super.toText(sym)
Expand All @@ -38,7 +34,12 @@ class ReplPrinter(_ctx: Context) extends DecompilerPrinter(_ctx) {
override def dclText(sym: Symbol): Text = if (debugPrint) super.dclText(sym) else
("lazy": Text).provided(sym.is(Lazy)) ~~
toText(sym) ~ {
if (sym.is(Method)) toText(sym.info)
if (sym.is(Method)) {
sym.info match {
case tp: ExprType => ":" ~~ toText(tp.resType)
case _ => toText(sym.info)
}
}
else if (sym.isType && sym.info.isTypeAlias) toText(sym.info)
else if (sym.isType || sym.isClass) ""
else ":" ~~ toText(sym.info)
Expand Down
8 changes: 8 additions & 0 deletions compiler/test-resources/repl/i9102
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
scala> def foo(x: => Int) = x.toString
def foo(x: => Int): String
scala> def bar: (=> Int) => String = x => x.toString
def bar: (=> Int) => String
scala> def baz: (Int => String) = x => x.toString
def baz: Int => String
scala> lazy val qux: ((=> Int) => String) = x => x.toString
lazy val qux: (=> Int) => String