www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17298] New: Templates cause wrong deprecation warnings about

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

          Issue ID: 17298
           Summary: Templates cause wrong deprecation warnings about
                    derived class accessing private method
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: maximzms gmail.com

Test code:

a.d:
----------
module a;

class Base
{
    private void func() {}
}

void foo(T)() { new T().func(); }  // line 8

struct Wrap(T)
{
    void boo() { new T().func(); }  // line 12
}

class Cover(T)
{
    void boo() { new T().func(); }  // line 17
}
----------

b.d:
----------
import a;

class Derived : Base {}

void main()
{
    foo!Base();    // OK
    foo!Derived(); // Deprecation warning

    alias A = Wrap!Base;    // OK
    alias B = Wrap!Derived; // Deprecation warning

    alias C = Cover!Base;    // OK
    alias D = Cover!Derived; // Deprecation warning
}
----------

dmd a b
----------
a.d(8): Deprecation: a.Base.func is not visible from class Derived
a.d(12): Deprecation: a.Base.func is not visible from class Derived
a.d(17): Deprecation: a.Base.func is not visible from class Derived
----------

--
Apr 05