| [#79] | project: compiler | priority: medium | category: bug | |
|---|---|---|---|---|
| submitter | assigned to | status | date submitted | |
| Matthias | Michel | fixed | 2003-07-21 14:05:26.0 | |
| subject | Too many methods mixed in | |||
| code |
object Test {
import scala.collection._;
def main(args: Array[String]) = {
val map =
new mutable.ImmutableMapAdaptor[Int, String, immutable.ListMap[Int, String]](
immutable.ListMap.Empty[Int, String]);
map += 1 -> "one";
map += 2 -> "two";
map -= 1;
System.out.println(map);
}
} |
|||
| what happened | Compiles, but when executing the program, the following exception is thrown:
|
|||
| what expected | In the Java interface representing scala.collection.mutable.ImmutableMapAdaptor there are two abstract toString methods. Of course, we want only one; in the optimal case even none! (since every interface defines implicitly a subtype of java.lang.Object. |
|||
| [back to overview] | ||||
| Matthias edited on 2003-07-21 14:05:49.0 |
| Matthias edited on 2003-07-21 14:08:04.0 |
| Michel edited on 2003-07-22 09:23:02.0 |
|
This was actually a bug in ImmutableMapAdaptor.scala, which defined the "toString" method twice. Since this is not catched (yet) by the compiler, it goes to the backend which generates two identical method definitions. I fixed ImmutableMapAdaptor, and your program now runs. As we discussed already several times, this should (and will) be fixed in Erasure. |
| Matthias edited on 2003-07-22 10:02:56.0 |
| Ah, this explains why I couldn't reduce the "bug".... Sorry! |