nested class inheritance
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sat Jul 14 04:51:32 PDT 2012
On 7/14/12 5:36 AM, Guillaume Chatelet wrote:
> class Fruit {
> class Seed {
> }
> }
>
> class Apple extends Fruit {
> class AppleSeed extends Fruit.Seed {
> Apple getOuter() {
> return Apple.this;
> }
> }
> }
>
> class Main {
> public static void main(String[] args) {
> final Apple apple = new Apple();
> final Apple.AppleSeed appleSeed = apple.new AppleSeed();
> assert (appleSeed instanceof Fruit.Seed);
> assert (apple == appleSeed.getOuter());
> assert (appleSeed.getOuter() instanceof Apple);
> assert (appleSeed.getOuter() instanceof Fruit);
> }
> }
>
> This is valid Java code actually and I agree with Gor I would have
> expected it to work with D.
>
> Guillaume
You may want to add the example to the bug report.
Thanks,
Andrei
More information about the Digitalmars-d
mailing list