[Issue 17824] New: wrong visibility deduced for method

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Sep 12 01:48:32 UTC 2017


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

          Issue ID: 17824
           Summary: wrong visibility deduced for method
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: nicolas.jinchereau at gmail.com

module base;
import derived;
class Base {
    private void foo() { }
    void callFoo(Derived d) { d.foo(); }
}
-------
module derived;
import base;
class Derived : Base { }
-------
import base;
import derived;
int main(string[] argv) {
    auto d = new Derived();
    d.callFoo(new Derived());
}

error:
base.d(6): Deprecation: base.Base.foo is not visible from class Derived

The method d.foo() should be callable from inside 'callFoo'. Casting 'd' to
'Base' inside 'callFoo()' before invoking 'foo' suppresses the error.

--


More information about the Digitalmars-d-bugs mailing list