Skip to content
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
8 changes: 5 additions & 3 deletions compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ class PlainPrinter(_ctx: Context) extends Printer {
"<noprefix>"
case tp: MethodType =>
changePrec(GlobalPrec) {
(if (tp.isImplicitMethod) "(implicit " else "(") ~ paramsText(tp) ~
("(" + (if (tp.isErasedMethod) "erased " else "")
+ (if (tp.isImplicitMethod) "implicit " else "")
) ~ paramsText(tp) ~
(if (tp.resultType.isInstanceOf[MethodType]) ")" else "): ") ~
toText(tp.resultType)
}
Expand Down Expand Up @@ -536,9 +538,9 @@ class PlainPrinter(_ctx: Context) extends Printer {
protected def literalText(text: Text): Text = coloredText(text, SyntaxHighlighting.LiteralColor)
protected def stringText(text: Text): Text = coloredText(text, SyntaxHighlighting.StringColor)

private def coloredStr(text: String, color: String): String =
protected def coloredStr(text: String, color: String): String =
if (ctx.useColors) color + text + SyntaxHighlighting.NoColor else text
private def coloredText(text: Text, color: String): Text =
protected def coloredText(text: Text, color: String): Text =
if (ctx.useColors) color ~ text ~ SyntaxHighlighting.NoColor else text
}

5 changes: 5 additions & 0 deletions compiler/src/dotty/tools/dotc/printing/ReplPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ class ReplPrinter(_ctx: Context) extends DecompilerPrinter(_ctx) {
else ":" ~~ toText(sym.info)
}
}

// We don't want the colors coming from RefinedPrinter as the REPL uses its
// own syntax coloring mechanism.
override def coloredStr(text: String, color: String): String = text
override def coloredText(text: Text, color: String): Text = text
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object SyntaxHighlighting {
private val tripleQs = Console.RED_B + "???" + NoColor

private val keywords: Seq[String] = for {
index <- IF to ENUM // All alpha keywords
index <- IF to ERASED // All alpha keywords
} yield tokenString(index)

private val interpolationPrefixes =
Expand Down
2 changes: 2 additions & 0 deletions compiler/test-resources/repl/3932
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scala> def fun[T](x: T): implicit List[T] => Int = ???
def fun[T](x: T): implicit List[T] => Int
2 changes: 2 additions & 0 deletions compiler/test-resources/repl/erased
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scala> def f(erased a: Int): Int = ???
def f(erased a: Int): Int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test case for erased implicit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

2 changes: 2 additions & 0 deletions compiler/test-resources/repl/erased-implicit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scala> def f(erased implicit a: Int): Int = ???
def f(erased implicit a: Int): Int