possible nested class/struct alias this bug
Eberhard
eberhardhoepfner at gmx.de
Sat Sep 28 08:34:33 PDT 2013
Hello,
I came across this unexpected error in the first example, so I
tested similar scenarios, but couldn't make any sense of it.
Thanks, Eberhard.
class A {
void foo() {}
static class B {
private A a;
alias a this;
void bar() {
this.foo(); // works fine
foo(); // Error: this for `foo` needs to be type
`A` not type `A.B`
}
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class A {
void foo() {}
}
class B {
void foo() {}
static class C {
private A a;
alias a this;
void bar() {
this.foo(); // works fine
foo(); // Error: this for `foo` needs to be type
`B` not type `B.C`
}
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class A {
void foo() {}
}
class B {
// no foo
static class C {
private A a;
alias a this;
void bar() {
this.foo(); // works fine
foo(); // works fine
}
}
}
More information about the Digitalmars-d-learn
mailing list