[Issue 23277] alias to mixin template breaks selective overriding of mixin template member

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 9 12:55:24 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23277

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305 at gmail.com

--- Comment #2 from RazvanN <razvan.nitu1305 at gmail.com> ---
(In reply to Adam D. Ruppe from comment #1)
> Actually, I don't think I completely reduced this; you can remove the alias
> param and still get it by just mentioning `impl` in the body.
> 
> This is further reduced:
> 
> ```
> interface A {
>         void foo();
>         void foo(int);
> }
> 
> mixin template C() {
>         void foo(){ return impl.foo(); }
>         void foo(int p){ return impl.foo(p); }
> }
> 
> class B : A {
>         A impl;
>         mixin C!() c;
>         void foo(int) {}
>         alias foo = c.foo;
> }
> ```
> 
> The alias line in the class is necessary to trigger the thing.

Hmm, to me it seems that you are trying to insert `void foo(int p)` in the same
overload set as `void foo(int)`. Shouldn't this be illegal? Otherwise, once you
call B.foo how can the compiler know which function should be called?

--


More information about the Digitalmars-d-bugs mailing list