Thread overview | ||||||
---|---|---|---|---|---|---|
|
August 22, 2013 Order matters on inheritance | ||||
---|---|---|---|---|
| ||||
I don't know what the expected behavior is but it seems odd/wrong: http://dpaste.dzfl.pl/a390f1f4 Note that there are two issues here(almost the same). First is that A.foo isn't called and second is that the order of inheritance on A matters(: X, Y vs : Y,X). I would expect that A.foo(A) should match first and the ambiguity created from the inheritance should result in an error. |
August 22, 2013 Re: Order matters on inheritance | ||||
---|---|---|---|---|
| ||||
Posted in reply to JS | On Thursday, 22 August 2013 at 01:43:45 UTC, JS wrote: > I don't know what the expected behavior is but it seems odd/wrong: > > http://dpaste.dzfl.pl/a390f1f4 > > Note that there are two issues here(almost the same). First is that A.foo isn't called and second is that the order of inheritance on A matters(: X, Y vs : Y,X). > > > I would expect that A.foo(A) should match first and the ambiguity created from the inheritance should result in an error. There is a bug out for this. Please upvote it. :) http://d.puremagic.com/issues/show_bug.cgi?id=10806 |
August 22, 2013 Re: Order matters on inheritance | ||||
---|---|---|---|---|
| ||||
Posted in reply to JS | On Thu, 22 Aug 2013 02:43:42 +0100, JS <js.mdnq@gmail.com> wrote: > I don't know what the expected behavior is but it seems odd/wrong: > > http://dpaste.dzfl.pl/a390f1f4 > > Note that there are two issues here(almost the same). First is that A.foo isn't called and second is that the order of inheritance on A matters(: X, Y vs : Y,X). > > > I would expect that A.foo(A) should match first and the ambiguity created from the inheritance should result in an error. I disagree that a.foo(A) should match, because.. You have a variable 'q' of type (interface) 'A' and you call method 'foo' on it. The compiler MUST only consider methods available on type (interface) 'A', which are: foo(X) foo(Y) It cannot call a.foo(A) (note 'a.foo' not 'A.foo') because while 'q' does in reality refer to an object of type 'a', you've asked it to interface to it via it's interface 'A' which does not have an overload foo(A). I do however agree that the compiler behaviour of silently selecting the foo from the first interface listed is wrong, it ought to give an error in this case IMO. Regan -- Using Opera's revolutionary email client: http://www.opera.com/mail/ |
August 22, 2013 Re: Order matters on inheritance | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | On Thursday, 22 August 2013 at 08:45:36 UTC, Regan Heath wrote:
> On Thu, 22 Aug 2013 02:43:42 +0100, JS <js.mdnq@gmail.com> wrote:
>
>> I don't know what the expected behavior is but it seems odd/wrong:
>>
>> http://dpaste.dzfl.pl/a390f1f4
>>
>> Note that there are two issues here(almost the same). First is that A.foo isn't called and second is that the order of inheritance on A matters(: X, Y vs : Y,X).
>>
>>
>> I would expect that A.foo(A) should match first and the ambiguity created from the inheritance should result in an error.
>
> I disagree that a.foo(A) should match, because..
>
> You have a variable 'q' of type (interface) 'A' and you call method 'foo' on it. The compiler MUST only consider methods available on type (interface) 'A', which are:
> foo(X)
> foo(Y)
> It cannot call a.foo(A) (note 'a.foo' not 'A.foo') because while 'q' does in reality refer to an object of type 'a', you've asked it to interface to it via it's interface 'A' which does not have an overload foo(A).
>
> I do however agree that the compiler behaviour of silently selecting the foo from the first interface listed is wrong, it ought to give an error in this case IMO.
>
Right, I forgot to add foo(A) to the interface. (I added it very quickly after the fact)
It works as expected when foo(A) is added to the interface so there is no problem with that aspect.
|
Copyright © 1999-2021 by the D Language Foundation