[Issue 14016] New: Nested inherited class doesn't know the type of its outer object
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Jan 20 05:02:06 PST 2015
https://issues.dlang.org/show_bug.cgi?id=14016
Issue ID: 14016
Summary: Nested inherited class doesn't know the type of its
outer object
Product: D
Version: D1 & D2
Hardware: All
OS: All
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: andrej.mitrovich at gmail.com
-----
class A
{
class NestedA { }
}
class B : A
{
int field;
class NestedB : NestedA
{
void foo ( )
{
this.outer.field = 1; // disallowed
(cast(B)this.outer).field = 1; // workaround
}
}
}
void main ( )
{
}
-----
$ dmd test.d
> test.d(14): Error: no property 'field' for type 'test.A'
I think the first line should work. AFAIK NestedB can only be instantiated with
an outer type B, therefore 'this.outer' should be implicitly derived to be of
type 'test.B'.
--
More information about the Digitalmars-d-bugs
mailing list