Aladdin - Scala Bugtracking
[#1042] project: compiler priority: low category: bug
submitter assigned to status date submitted
Adriaan Martin fixed 2007-04-12 10:15:49.0
subject toString not generated in case class if overloaded version exists
code
abstract class  A {
  override def toString(): String // crucial

  def toString(sb: StringBuilder): StringBuilder // crucial
}

case class B extends A {
  // overloaded version is implemented, causing toString not to be implemented?
  def toString(sb: StringBuilder): StringBuilder = error("")
}

object Test extends Application {
  Console.println(B)
}
what happened
java.lang.AbstractMethodError
        at java.lang.String.valueOf(String.java:2615)
        at java.io.PrintStream.print(PrintStream.java:616)
        at java.io.PrintStream.println(PrintStream.java:753)
        at scala.Console$.println(Console.scala:161)
        at Test$.(a.scala:13)
        at Test$.(a.scala)
        at Test.main(a.scala)
...
what expected either B gets a generated toString method or it is flagged as abstract (imo, it comes to down to what the semantics are for the abstract override for toString in A --> does this mean a subclass has to implement it explicitly?)
[back to overview]
Changes of this bug report
Adriaan  edited on  2007-04-12 11:27:23.0
originally reported as a bug in the xml library, but Burak rightfully noted that it's really a compiler bug
Martin  edited on  2007-04-12 15:25:57.0