I am not sure. b is C but everything not in super class B is
hidden.
Using cast I can cast b to a full C.
The cast "cast(C)b" has the same information about b like the
cast "cast(A)b": The memory area of b knows compatitibility to C
and also the alias.
For me, using alias this, the object b has 3 represenations: A, B
and C. It is a matter of steps.
Kind regards
André
On Thursday, 11 September 2014 at 11:53:30 UTC, Daniel Kozak via
Digitalmars-d-learn wrote:
V Thu, 11 Sep 2014 11:40:05 +0000
andre via Digitalmars-d-learn
<digitalmars-d-learn@puremagic.com>
napsáno:
Hi,
I am 80% sure, the failing assertion is correct but please
have a look.
No it is not
assert(cast(A)cast(C)b); // this is OK
b is B so it does not know about having alias to A;
Second assertion fails.
Kind regards
André
class A{}
class B{}
class C : B
{
A a;
alias a this;
this()
{
a = new A();
}
}
void main()
{
B b = new C();
// OK
assert(cast(C)b);
// fails
assert(cast(A)b);
}