diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index 12c5eec5fd1a..f3153592a73c 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -169,7 +169,9 @@ class PlainPrinter(_ctx: Context) extends Printer { "" 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) } @@ -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 } diff --git a/compiler/src/dotty/tools/dotc/printing/ReplPrinter.scala b/compiler/src/dotty/tools/dotc/printing/ReplPrinter.scala index acd43d1848f7..84d0cae359cd 100644 --- a/compiler/src/dotty/tools/dotc/printing/ReplPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/ReplPrinter.scala @@ -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 } diff --git a/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala b/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala index 08a34a2e9fbc..d35e34b92b7b 100644 --- a/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala +++ b/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala @@ -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 = diff --git a/compiler/test-resources/repl/3932 b/compiler/test-resources/repl/3932 new file mode 100644 index 000000000000..c8e3ae2c4c68 --- /dev/null +++ b/compiler/test-resources/repl/3932 @@ -0,0 +1,2 @@ +scala> def fun[T](x: T): implicit List[T] => Int = ??? +def fun[T](x: T): implicit List[T] => Int diff --git a/compiler/test-resources/repl/erased b/compiler/test-resources/repl/erased new file mode 100644 index 000000000000..9a67c1963769 --- /dev/null +++ b/compiler/test-resources/repl/erased @@ -0,0 +1,2 @@ +scala> def f(erased a: Int): Int = ??? +def f(erased a: Int): Int diff --git a/compiler/test-resources/repl/erased-implicit b/compiler/test-resources/repl/erased-implicit new file mode 100644 index 000000000000..652b1e17e7a3 --- /dev/null +++ b/compiler/test-resources/repl/erased-implicit @@ -0,0 +1,2 @@ +scala> def f(erased implicit a: Int): Int = ??? +def f(erased implicit a: Int): Int