Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot access derived protected method in another module #19594

Open
dlangBugzillaToGithub opened this issue Jun 25, 2019 · 0 comments
Open

Cannot access derived protected method in another module #19594

dlangBugzillaToGithub opened this issue Jun 25, 2019 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

Andrej Mitrovic (@AndrejMitrovic) reported this on 2019-06-25T06:44:16Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=20002

Description

This is similar to https://issues.dlang.org/show_bug.cgi?id=2417.

Test-case:

base.d:
```
import derived;

class Base
{
    protected void func() { }
}

void main()
{
    auto derived = new Derived;
    derived.func();
}
```

derived.d:
```
import base;

class Derived : Base
{
    protected override void func() { }
}
```

~/dev/d master * $ dmd -run base.d
base.d(11): Deprecation: derived.Derived.func is not visible from module base
base.d(11): Error: class `derived.Derived` member func is not accessible


The fix is to change:
auto derived = new Derived;

to:
Base derived = new Derived;

But I don't see why the compiler can't access it in the first case, it's still a virtual call after all..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant