Method overrides and covariant return types

Daniel Bonniot <[email protected]> Wed, 03 Mar 2004 17:04:21 +0100
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
Hi,

The development version now implements method overrides. Simple example:

      class A {
        A doSomething() { ... }
      }
      class B extends A {
        override B doSomething() { ... }
      }

(the same thing is also possible outside classes of course)

This brings two benefits. One is the possibility to make the return type 
more precise (covariance). The other is to support the traditional style 
of method override, when the override keyword is omitted. This generates 
a warning, advising to either add the keyword or (provided the return 
type is the same) just leave the return type out. The rationale is that 
overriding should be explicit, since that prevents against surprises 
when you write a new method implementation, or when an imported library 
modifies the signature of a method you used to override.

Testing and comments are welcome.

Daniel



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click