Jump to page: 1 2
Thread overview
[Issue 2563] New: Derived class is implicitly castable to Base class when inherited privately
Jan 07, 2009
d-bugmail
Jan 07, 2009
d-bugmail
Jan 07, 2009
d-bugmail
Jan 07, 2009
d-bugmail
Jan 07, 2009
Extrawurst
Jan 07, 2009
d-bugmail
Mar 17, 2010
Stewart Gordon
Jan 30, 2012
yebblies
Jan 30, 2012
Stewart Gordon
Jan 30, 2012
yebblies
January 07, 2009
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
}


-- 

January 07, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2563





------- Comment #1 from jarrett.billingsley@gmail.com  2009-01-07 14:10 -------
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.


-- 

January 07, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2563


spam@extrawurst.org changed:

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




------- Comment #2 from spam@extrawurst.org  2009-01-07 14:22 -------
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.


-- 

January 07, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2563





------- Comment #3 from 2korden@gmail.com  2009-01-07 14:29 -------
(In reply to comment #1)
> 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.


-- 

January 07, 2009
d-bugmail@puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=2563
> 
> 
> 
> 
> 
> ------- Comment #3 from 2korden@gmail.com  2009-01-07 14:29 -------
> (In reply to comment #1)
>> 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!
January 07, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2563


smjg@iname.com changed:

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




------- Comment #4 from smjg@iname.com  2009-01-07 15:36 -------
(In reply to comment #2)
> 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.


-- 

March 17, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2563


Stewart Gordon <smjg@iname.com> changed:

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


--- Comment #5 from Stewart Gordon <smjg@iname.com> 2010-03-17 13:19:28 PDT ---
*** 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: -------
January 30, 2012
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


--- Comment #6 from yebblies <yebblies@gmail.com> 2012-01-30 17:00:53 EST ---
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: -------
January 30, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=2563



--- Comment #7 from Stewart Gordon <smjg@iname.com> 2012-01-30 04:33:58 PST ---
(In reply to comment #6)
> 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: -------
January 30, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=2563



--- Comment #8 from yebblies <yebblies@gmail.com> 2012-01-31 02:29:01 EST ---
(In reply to comment #7)
> 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: -------
« First   ‹ Prev
1 2