Re: Method overrides and covariant return types

[email protected] Thu, 4 Mar 2004 14:05:33 -0600
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
I tested all the examples I posted from the "Covariant Return Types" thread and
they all seemed to work fine, except for one (see below). In addition, I did all
these tests on the JDK 1.5 beta and there were no JDK 1.5-related problems. But,
that is very limited testing.

Quoting Isaac Gouy <[email protected]>:
> Quoting Daniel:
> > The development version now implements method overrides
> 
> Is there a way a compiler switch to hide warnings?
> (Yes we will want to see them, but maybe we need to fix errors first.)

I think that the warning should be changed to an error. That is, your code
should not compile if it is using implicit overriding.

> What's the story with overloading now?

There is still one problem. If you have overloaded a method in such a way that
it _could_ override another method, then the compiler _forces_ the overriding.
That is, I can't find a way to say "This method does not override a method with
the same name and with contravariant parameters," like in f.doSomethingElse(B)
below.

package c;

class A { }
A doSomething(A a) { return a; }

package d;
import c;
void doSomethingElse(A a) { }

package e;
import c;
void doSomethingElse(A a) { }

package f;
import c;
import d;
import e;
class B extends A { }
override B doSomething(B a) { }
// This isn't supposed to override anything
void doSomethingElse(B b) { }   





-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click