You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 modificationsoverride 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
The text was updated successfully, but these errors were encountered:
RazvanN (@RazvanN7) reported this on 2017-12-27T14:19:07Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=18132
CC List
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, RazvanNThe text was updated successfully, but these errors were encountered: