I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof where it says:

"typeof(this) will generate the type of what this would be in a non-static member function, even if not in a member function. "

From that I got the impression that the code below would print the same result, but it doesn't. It prints:

main.Bar
main.Foo

instead of:

main.Foo
main.Foo

Is this a bug or have I misunderstood the docs?


module main;

import std.stdio;

class Bar
{
        void method ()
        {
                writeln(typeid(typeof(this)));
                writeln(typeid(this));
        }
}

class Foo : Bar {}

void main ()
{
        auto foo = new Foo;
        foo.method;
}

--
/Jacob Carlborg

Reply via email to