Bug 14016 – Nested inherited class doesn't know the type of its outer object
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-01-20T13:02:00Z
Last change time
2017-07-19T17:38:58Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2015-01-20T13:02:06Z
-----
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'.