D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 18132 - mixin template methods ignored in inheritance chain
Summary: mixin template methods ignored in inheritance chain
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 All
: P3 normal
Assignee: No Owner
URL:
Keywords:
: 22879 (view as issue list)
Depends on:
Blocks:
 
Reported: 2017-12-27 14:19 UTC by RazvanN
Modified: 2024-12-13 18:55 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description RazvanN 2017-12-27 14:19:07 UTC
Consider the following example:

import core.stdc.stdio;

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

mixin template Bmix(AST)
{

    // move these 2 methods inside B without any modifications
    override void visit(int a) {printf("B - int\n");}
    override void visit(float b) {printf("B - float\n"); 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\n");
        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
Comment 1 Tim 2022-03-12 13:39:34 UTC
*** Issue 22879 has been marked as a duplicate of this issue. ***
Comment 2 dlangBugzillaToGithub 2024-12-13 18:55:48 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

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

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