Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mixin template methods ignored in inheritance chain #19355

Open
dlangBugzillaToGithub opened this issue Dec 27, 2017 · 1 comment
Open

mixin template methods ignored in inheritance chain #19355

dlangBugzillaToGithub opened this issue Dec 27, 2017 · 1 comment
Labels
Arch:x86_64 Issues specific to x86_64 P3 Severity:normal

Comments

@dlangBugzillaToGithub
Copy link

RazvanN (@RazvanN7) reported this on 2017-12-27T14:19:07Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=18132

CC List

  • Tim

Description

Consider the following example:

import core.stdc.stdio;

class A
{
    void visit(int a){ printf("A - int
");}
    void visit(float b) { printf("A - float
");}
}

mixin template Bmix(AST)
{

    // move these 2 methods inside B without any modifications
    override void visit(int a) {printf("B - int
");}
    override void visit(float b) {printf("B - float
"); super.visit(b);}
}

class B : A!int
{
    alias visit = A!int.visit;
    mixin Bmix!int;

}

class C : B 
{
    alias visit = B.visit;

    override void visit(float b)
    {   
        printf("C - float
");
        super.visit(b);
    }   
}

void main()
{
    C vis = new C();
    float c = 7.0;
    vis.visit(c);
}

Output:
C - float
A - float

Moving the visit methods from Bmix to B results in the following output:
C - float
B - float
A - float

I would expect that this is also the result in the first case.

Best regards,
RazvanN
@dlangBugzillaToGithub
Copy link
Author

tim.dlang commented on 2022-03-12T13:39:34Z

*** Issue 22879 has been marked as a duplicate of this issue. ***

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch:x86_64 Issues specific to x86_64 P3 Severity:normal
Projects
None yet
Development

No branches or pull requests

1 participant