[Issue 3113] final overriding

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 16 06:53:25 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=3113



--- Comment #7 from yebblies <yebblies at gmail.com> 2011-06-16 06:48:41 PDT ---
(In reply to comment #5)
> 
> Remove the »final« attribute and compile the example with -w, and you'll see.
> 

I get an error when compiling without the final attribute, -w or not.

testx.d(21): Error: function testx.DerivedClass.getEnum of type B() overrides
but is not covariant with testx.BaseClass.getEnum of type A()

> Besides, since when would it be allowed to have two public methods with the
> same signature?

Yes, overloading on return type is disabled for functions in the same scope,
but the rules are a little less strict for deriving classes...
Looking at the spec, it seems to be explicitly disallowed for functions that
would otherwise be virtual.
It can be very useful with template functions, as they need to be redefined in
each class, and is allowed for static functions.

I might be misunderstanding, please post a test case that shows what you mean.

(In reply to comment #6)
> Even if D is working according to specs, I think this is bug-prone enough to
> deserve some warning or even an error.

I think it would be much clearer if override was mandatory, and I'm fairly sure
there's already a report for that.  If there's something else you'd like,
please, write it up.  A test case that compiles does not constitute an
enhancement request without additional information. (unless it's very, very
obvious)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list