The following code compiles and works using DMD 1.051. When trying to compile with LDC, I get Error: need 'this' to access foo pointing to the cost line in the template.
The test case triggering the error:
template addressOf( alias fn ) {
const addressOf = &fn;
}
class A {
void foo() {}
final void bar() {
auto dg = &foo;
if ( addressOf!( foo ) == dg.funcptr ) {
Stdout( "not overridden" ).newline;
} else {
Stdout( "overridden" ).newline;
}
}
}
class B : A {
override void foo() {}
}
void main() {
A a = new A();
a.bar;
A b = new B();
b.bar;
}