www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13197] New: 'package' visibility bug

https://issues.dlang.org/show_bug.cgi?id=13197

          Issue ID: 13197
           Summary: 'package' visibility bug
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: turkeyman gmail.com

I have a problem where a base class has some member with package protection,
and a class that derives from the base seems to hijack the base classes
visibility constraints.

In the example in f(), i can access the base class directly, but I can't access
it via the derived class, even though it should (?) be accessible...

If i 'cast(C)D", then I can call f(), as expected. I shouldn't have to perform
this case to access package visible base members.

-----------------------

module x.a;

import x.y;   // import class C
import x.y.z; // import class D : C

void f()
{
  C c;
  c.f(); // no problem, C is declared in the same package

  D d;
  d.f(); // error! D doesn't define f(), C does, and we have access to C as
demonstrated above
}

-----------------------

module x.y;

class C
{
package:
  void f()
  {
  }
}

-----------------------

module x.y.z;

class D : C
{
}

--
Jul 24 2014