diff options
author | Geoffrey Washburn <geoffrey.washburn@epfl.ch> | 2008-10-08 15:32:52 +0000 |
---|---|---|
committer | Geoffrey Washburn <geoffrey.washburn@epfl.ch> | 2008-10-08 15:32:52 +0000 |
commit | bd46c931f0fba3a9bee8816a7b2fb77ed33bc361 (patch) | |
tree | efef9c3b5c5e59e7d8d42bb2b6e22adac94d13f5 | |
parent | 29a8a8f77998b640f5083e87cd735301dd63922a (diff) | |
download | scala-bd46c931f0fba3a9bee8816a7b2fb77ed33bc361.tar.gz scala-bd46c931f0fba3a9bee8816a7b2fb77ed33bc361.tar.bz2 scala-bd46c931f0fba3a9bee8816a7b2fb77ed33bc361.zip |
Fix for #547 and #1404.
-rw-r--r-- | src/compiler/scala/tools/nsc/Interpreter.scala | 3 | ||||
-rw-r--r-- | test/files/run/interpreter.check | 9 | ||||
-rw-r--r-- | test/files/run/interpreter.scala | 6 |
3 files changed, 17 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index 99606e856f..09b8c6f068 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -627,7 +627,8 @@ class Interpreter(val settings: Settings, out: PrintWriter) { ".asInstanceOf[AnyRef] != null) " + " { val tmp = " + req.fullPath(vname) + - ".toString(); " + + // Cast to Any to avoid ambiguity in choice of toString + ".asInstanceOf[Any].toString(); " + " (if(tmp.contains('\\n')) \"\\n\" else \"\") + tmp + \"\\n\"} else \"null\\n\") ") } } diff --git a/test/files/run/interpreter.check b/test/files/run/interpreter.check index ef8de4dc97..64eeca14ba 100644 --- a/test/files/run/interpreter.check +++ b/test/files/run/interpreter.check @@ -34,6 +34,15 @@ scala> hello scala> scala> +scala> atom: scala.xml.Atom[Unit] = () + +scala> +scala> defined class S + +scala> fish: S = fish + +scala> +scala> scala> defined class Foo scala> defined class Bar diff --git a/test/files/run/interpreter.scala b/test/files/run/interpreter.scala index 13abc565f7..1ebe72ed2a 100644 --- a/test/files/run/interpreter.scala +++ b/test/files/run/interpreter.scala @@ -22,6 +22,12 @@ trait PointlessTrait val (x,y) = (2,3) println("hello") +// ambiguous toString problem from #547 +val atom = new scala.xml.Atom() +// overriding toString problem from #1404 +class S(override val toString : String) +val fish = new S("fish") + // implicit conversions case class Foo(n: Int) case class Bar(n: Int) |