Inheriting from an interface twice

Denis Koroskin 2korden at gmail.com
Mon Oct 4 04:46:34 PDT 2010


On Mon, 04 Oct 2010 15:39:46 +0400, Steven Schveighoffer  
<schveiguy at yahoo.com> wrote:

> On Fri, 01 Oct 2010 04:32:24 -0400, Denis Koroskin <2korden at gmail.com>  
> wrote:
>
>> I always thought that in D interface inheritance is always virtual,  
>> i.e. you only inherit it once even if it is specified twice (or more)  
>> within hierarchy.
>>
>> Until I got an assertion on the following test (reduced from a real  
>> example):
>>
>> interface Foo
>> {
>> }
>>
>> class Bar : Foo
>> {
>> }
>>
>> class Baz : Bar, Foo
>> {
>> }
>>
>> void main()
>> {
>> 	Baz baz = new Baz();
>> 	Bar bar = baz;
>> 	
>> 	Foo foo1 = bar;
>> 	Foo foo2 = baz;
>> 	
>> 	assert(foo1 is foo2);
>> }
>>
>>
>> foo1 and foo2 have the same type and point to the same object. Yet they  
>> have different addresses. Is it a bug, or a feature?
>>
>> The test above passes for C# (http://ideone.com/xK5Mu) and C++  
>> (http://ideone.com/MnnL8 virtual inheritance used, fails otherwise, of  
>> course).
>
> I agree, I think you should file a bug on this.
>
> -Steve

Already done: http://d.puremagic.com/issues/show_bug.cgi?id=4979


More information about the Digitalmars-d mailing list