method returning child, doesn't overrides declared method returning parent

Mariusz Gliwiński alienballance at gmail.com
Mon Aug 29 23:57:53 PDT 2011


Jonathan M Davis wrote:
> This seems to compile just fine:
> 
> interface Interface
> {
>  Interface method();
> }
> class Class : Interface
> {
>  Class method() {return new Class;}
> }
> 
> The problem is the override keyword. _No_ overriding is going on. _That's_
> why it's complaining.

I'm sorry - i provided wrong example. I had property in my code, and he 
didn't complained about getter, but setter (of course he can't diversify by 
different return values).

<code>
interface Interface
{
	void method(Interface);
}
class Class : Interface
{
	void method(Class) {}
}

void main() {}
</code>

So, You're saying it should be possible, and this is DMD bug? So i'll report 
that.

Thanks,
Mariusz G.


More information about the Digitalmars-d mailing list