www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8389] New: Classes, nested in the same base class cannot be derived from.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8389

           Summary: Classes, nested in the same base class cannot be
                    derived from.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: gor boloneum.com



---
class Fruit
{
    class Seed {} // Not static, because this.outer is necessary
}

class Apple: Fruit
{
    class RedAppleSeed: Fruit.Seed {} 
    class GreenAppleSeed: Fruit.Seed {}
}

DMD 2.059:

Error: class main.Apple.RedAppleSeed is nested within Apple, but super class
Seed is nested within Fruit
Error: class main.Apple.GreenAppleSeed is nested within Apple, but super class
Seed is nested within Fruit

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 13 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8389


Guillaume Chatelet <chatelet.guillaume gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |chatelet.guillaume gmail.co
                   |                            |m



2012-07-14 05:09:35 PDT ---
Indeed. The following is valid Java code and I would have expected it to work
with D too as D took the Java way for OOP.

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);
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 14 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8389


Guillaume Chatelet <chatelet.guillaume gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE



2012-07-14 05:15:02 PDT ---
*** This issue has been marked as a duplicate of issue 1175 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 14 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8389


David Piepgrass <qwertie256 gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |qwertie256 gmail.com



PDT ---
So this is a regression?

I am using this feature in my Android Java code too.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 14 2012