Skip to content

Commit 592f267

Browse files
authored
Merge pull request #2937 from dotty-staging/i2929
Fix #2929: REPL error for classes with a show method
2 parents 12be03e + db2ecac commit 592f267

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ class CompilingInterpreter(
724724
| if ($fullPath.asInstanceOf[AnyRef] != null) {
725725
| (if ($fullPath.toString().contains('\\n')) "\\n" else "") + {
726726
| import dotty.Show._
727-
| $fullPath.show /*toString()*/ + "\\n"
727+
| (new ShowValue($fullPath)).show /*toString()*/ + "\\n"
728728
| }
729729
| } else {
730730
| "null\\n"

tests/repl/showMethod.check

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
scala> class A { def show = "hello"; override def toString = "A" }
2+
defined class A
3+
scala> new A
4+
val res0: A = A
5+
scala> class B { def show() = "hello"; override def toString = "B" }
6+
defined class B
7+
scala> new B
8+
val res1: B = B
9+
scala> :quit

0 commit comments

Comments
 (0)