[Issue 6083] [tdpl] There can be only one alias this.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 26 07:42:50 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=6083


Adam D. Ruppe <destructionator at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |destructionator at gmail.com


--- Comment #5 from Adam D. Ruppe <destructionator at gmail.com> 2014-02-26 07:42:39 PST ---
I'm not so sure about the ambiguity thing. Consider the following case of a
wrapped NotNull!T:

interface A { void foo(); }
interface B {}
class C : A, B { void foo() {} }
class D : C {}

NotNull!D should implicitly cast to D (a not null is always a maybe null),
which gives access to the methods, as well as NotNull!C - classes can always
implicitly cast to their base.

NotNull!C should implicitly cast to C, NotNull!A, NotNull!B, and
NotNull!Object.


Now consider we call

NotNull!D d = ...;
d.foo();

what happens?

1) foo is not a member of NotNull!D, so we try to match the alias thises.

2) D.foo works, so we add that to the ok list.

3) NotNull!C doesn't work, which triggers its list: C.foo also works.


Is this an error? C.foo and D.foo refer to the same function, since it is an
overridden virtual, but it would compile as both and might be considered
ambiguous.

However it is implemented, I'd argue it is important that this works since this
is one of my main use cases for multiple alias this.

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


More information about the Digitalmars-d-bugs mailing list