[Issue 15897] private base class method not seen through derived class

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed May 4 00:41:43 PDT 2016


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

--- Comment #14 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to Martin Nowak from comment #12)
> Yeah, we introduced sort of a new concept, "visibility through something",
> i.e. with the following import chain pkg.A -> B -> pkg.C, pkg.A cannot see
> package(pkg) protected symbols from pkg.C, even when B publically imports
> pkg.C.
> The same applies for base classes.
> 
> Visibility can only be restricted but not be widened later on, which is a
> fairly intuitive behavior and follows the same principle as the overload
> resolution w/ mixed protection, making it mostly independent from lookup
> origin.
> http://wiki.dlang.org/DIP22#Description

How the new concept works for aliased symbols *through* template alias
parameters? For example:

module a;
import b;
class C
{
   private int a;
}

void test()
{
   auto c = new C();
   assert(c.a == 0);
   Foo!c.foo();
   assert(c.a == 1);   
}

module b;

template Foo(alias var)
{
    void foo() { var.a = 1; }  // accessing private symbol via alias parameter
}

I thought it could be accepted case, but won't it be accepted anymore?

--


More information about the Digitalmars-d-bugs mailing list