[#1244] | project: compiler | priority: low | category: bug | |
---|---|---|---|---|
submitter | assigned to | status | date submitted | |
Stephane | Martin | open | 2007-07-26 13:53:37.0 | |
subject | method compareTo not defined | |||
code |
object test extends Application { val x1 = new java.io.File("x1") val x2 = new java.io.File("x2") { //override def compareTo(o: Any): Int = 0 // required! def hello() { println("4") } } println(x1.getName) println(x2.getName) x2.hello() } |
|||
what happened | test.scala:3: error: object creation impossible, since method compareTo in trait Comparable of type (Any)Int is \ not defined val x2 = new java.io.File("x2") { ^ one error found |
|||
what expected | compiles (code runs fine if you uncomment the user-defined compareTo method) | |||
[back to overview] |
Stephane edited on 2007-07-26 13:54:24.0 |
Martin edited on 2007-07-27 00:50:38.0 |
In fact this has nothing to do with structural types. The same error happens if you write new File("") {} The problem is that bridge methods for Java code are ignored, so the compiler does not realise that compareTo(File) in class File implements compareTo(Object) in class Comparable. The problem should go away once we interprete Java generics. Let's keep the bug open until then. |
Martin edited on 2007-07-27 10:06:12.0 |