#1396 Java subclass method visibility widening disallows Fantom overriding

groves Tue 18 Jan 2011

If I have a Java class

package test;
public class JavaMethod {
    protected void meth () {}
}

with a subclass

package test;
public class PublicJavaMethod extends JavaMethod {
    public void meth () {}
}

I can't override the method in a Fan class

using [java] test::PublicJavaMethod as PublicJavaMethod
class FanSub : PublicJavaMethod {
    override public Void meth () {}
}

The compiler complains that the method is overloaded: "/Users/charlie/Desktop/fan/test.fan(3,5): Cannot override Java overloaded method: meth". If PublicJavaMethod.meth is protected, I can override it from Fan.

brian Wed 19 Jan 2011

Promoted to ticket #1396 and assigned to brian

brian Wed 2 Mar 2011

Ticket resolved in 1.0.58

Java methods use declaring class for equality/hash which was screwing up the compiler's reflection code. I added a proper hash key for detecting public overrides of protected methods, so all should be good.

changeset

Login or Signup to reply.