From db2ecac66a2b4b813148707e26aa5f9b35daecd7 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Mon, 31 Jul 2017 17:22:35 +0200 Subject: [PATCH] Fix #2929: REPL error for classes with a show method Don't rely on implicit conversion to call the .show method --- .../src/dotty/tools/dotc/repl/CompilingInterpreter.scala | 2 +- tests/repl/showMethod.check | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/repl/showMethod.check diff --git a/compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala b/compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala index ca38ba10777a..85f47692f4fa 100644 --- a/compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala +++ b/compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala @@ -724,7 +724,7 @@ class CompilingInterpreter( | if ($fullPath.asInstanceOf[AnyRef] != null) { | (if ($fullPath.toString().contains('\\n')) "\\n" else "") + { | import dotty.Show._ - | $fullPath.show /*toString()*/ + "\\n" + | (new ShowValue($fullPath)).show /*toString()*/ + "\\n" | } | } else { | "null\\n" diff --git a/tests/repl/showMethod.check b/tests/repl/showMethod.check new file mode 100644 index 000000000000..428e3a2f6ed1 --- /dev/null +++ b/tests/repl/showMethod.check @@ -0,0 +1,9 @@ +scala> class A { def show = "hello"; override def toString = "A" } +defined class A +scala> new A +val res0: A = A +scala> class B { def show() = "hello"; override def toString = "B" } +defined class B +scala> new B +val res1: B = B +scala> :quit