Copied from bugzilla:
--- Comment #0 from Max Samukha <[email protected]> 2010-12-27
03:59:11 PST ---
class A
{
}
class B
{
A a;
alias a this;
}
class C : B
{
}
void main()
{
A a = new C; // error
}
Error: cannot implicitly convert expression (new C) of type test.C to test.A
Since C is a subtype of B (via inheritance) and B is a subtype of A (via
"alias
this"), C should be implicitly convertible to A.
--- Comment #1 from Walter Bright <[email protected]> 2010-12-27
13:33:28 PST ---
Yes, I see the problem. Never thought of that.
---
I must say after a long thought I *may* see the problem too, but...
Would you guys mind explaining what should this mean? How is it inferred
that C should be "implicitly" convertible to A in this case? I see a way
of substituting the *existing* reference, but construction? What if B or
C aren't visible during compilation (e.g. are introduced later in a
separate shared library)?