Nikolay edited on 2005-06-29 10:44:31.0
|
Transferred from the bug contributions.
|
Nikolay edited on 2005-06-29 10:56:44.0
|
The problem seems to be the name of the 'eq' method. If I change it to 'equ' the compiler catches the error. Maybe the AnyRef.eq method interferes with typechecking. In Definitions it is created as 'final' but this doesn't prevent from overloading it in subclasses, like this example shows:
class Foo {
def eq(f: Foo): Boolean = true;
}
object Test {
def main(args: Array[String]): Unit = {
val f1, f2 = new Foo();
System.out.println(f1 eq f2);
System.out.println(f1 eq (f2: AnyRef));
}
}
Maybe we should forbid defining methods with names 'eq' or 'ne' and hardcode it in the compiler.
|
Martin edited on 2005-06-29 17:29:56.0
|
The problem is indeed the `eq' method which takes AnyRef parameter. Your `eq' definition in class Foo just created a new overloaded version for it. This version does not match, but the original, inherited version does. Hence, all this is a consequence of the static overloading scheme, not an error.
|