On Tuesday, 25 December 2018 at 22:07:07 UTC, Johannes Loher
wrote:
Thanks a lot for the info, that clarifies things a bit. But it
still leaves the question, why it works correctly when
inheriting from an abstract class instead of implementing an
interface... Any idea about why that?
Unlike interfaces, base class references don't need adjustment.
You can see this in action by printing addresses:
https://run.dlang.io/is/m6icVr
import std.stdio;
interface I {}
class Base : I {}
class Derived : Base { }
void main()
{
auto derived = new Derived;
Base base = derived;
I i = derived;
writeln(cast(void*)derived);
writeln(cast(void*)base);
writeln(cast(void*)i);
}
7FC1F96EE000
7FC1F96EE000
7FC1F96EE010