Thread overview
[Issue 23277] alias to mixin template breaks selective overriding of mixin template member
Jul 31, 2022
Adam D. Ruppe
Aug 09, 2022
RazvanN
Aug 09, 2022
Adam D. Ruppe
Dec 17, 2022
Iain Buclaw
July 31, 2022
https://issues.dlang.org/show_bug.cgi?id=23277

--- Comment #1 from Adam D. Ruppe <destructionator@gmail.com> ---
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.

--
August 09, 2022
https://issues.dlang.org/show_bug.cgi?id=23277

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

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

--- Comment #2 from RazvanN <razvan.nitu1305@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?

--
August 09, 2022
https://issues.dlang.org/show_bug.cgi?id=23277

--- Comment #3 from Adam D. Ruppe <destructionator@gmail.com> ---
The overload set merging actually works perfectly fine. Declarations in the class itself override things that are mixed in, so it will always call the one from the class if the arguments match.

The problem here is the compiler doesn't allow it with the specific scenario when you are trying to forward the call to a member variable.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=23277

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

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

--- Comment #4 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/20136

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--