www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2563] New: Derived class is implicitly castable to Base class when inherited privately

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

           Summary: Derived class is implicitly castable to Base class when
                    inherited privately
           Product: D
           Version: 2.023
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: 2korden gmail.com


module A;

class A1
{
    void foo();
}

class A2 : private A1
{
}

module B;

void main() {
    A2 a2 = new A2();
    // a2.foo(); // Error: class A.A2 member foo is not accessible

    A1 a1 = a2;  // This line should yield an error
    a1.foo();    // ta-dam! Private method invoked
}


-- 
Jan 07 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2563






Why is public/private/protected inheritance even supported?  I think this is
more a strange artifact in the compiler/grammar than anything else.  When you
don't have MI, anything but public inheritance is useless.


-- 
Jan 07 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2563


spam extrawurst.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |spam extrawurst.org





afaik public/private/protected inheritance is not supported in D it is just not
prohibited to write it like in the sample though it always is publicly
inherited. there should be a bug for enhancement to stop permiting this
confusing syntactical feature.


-- 
Jan 07 2009
prev sibling next sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2563







 Why is public/private/protected inheritance even supported?  I think this is
 more a strange artifact in the compiler/grammar than anything else.  When you
 don't have MI, anything but public inheritance is useless.
 
No, it's useful to hide implementation details. --
Jan 07 2009
parent Extrawurst <spam extrawurst.org> writes:
d-bugmail puremagic.com wrote:
 http://d.puremagic.com/issues/show_bug.cgi?id=2563
 
 
 
 
 


 Why is public/private/protected inheritance even supported?  I think this is
 more a strange artifact in the compiler/grammar than anything else.  When you
 don't have MI, anything but public inheritance is useless.
No, it's useful to hide implementation details.
wooops right its documented like this aswell. sorry, its a bug!
Jan 07 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2563


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
           Keywords|                            |accepts-invalid






 afaik public/private/protected inheritance is not supported in D it 
 is just not prohibited to write it like in the sample though it 
 always is publicly inherited.
What do you believe is the reason that D grammar goes out of its way to allow this syntax?
 there should be a bug for enhancement to stop permiting this 
 confusing syntactical feature.
Issue 177 Notice the real reason the feature doesn't make sense: it hides the methods defined in Object, which are meant to be part of every class. --
Jan 07 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2563


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



*** Issue 3774 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 17 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2563


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com
           Platform|x86                         |All
            Version|2.023                       |D1
         OS/Version|Windows                     |All



D1 only now, as of issue 5299 private inheritance is deprecated in D2.

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





 D1 only now, as of issue 5299 private inheritance is deprecated in D2.
But it hasn't actually _worked_ in D1 for some time, and the spec has never actually given its meaning. As such, it would be to the point to just remove it from the grammar or at least issue a warning when one tries to use it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 30 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2563





 But it hasn't actually _worked_ in D1 for some time, and the spec has never
 actually given its meaning.  As such, it would be to the point to just remove
 it from the grammar or at least issue a warning when one tries to use it.
Yes... I don't recall stating anything to the contrary. If you thing the same fix (or a different fix) should be applied to D1 please reopen the closed issue (or a new issue) with that information. This bug is about the protection issue. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 30 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2563


Alex Rønne Petersen <alex lycus.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |alex lycus.org
         Resolution|                            |WONTFIX



CEST ---
Considering D1 is close to being discontinued and this feature is long
deprecated in D2, I think it's safe to close this. I don't see anyone ever
getting around to fixing it, so keeping it open is somewhat pointless.

(Feel free to reopen if you disagree.)

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