D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20002 - Cannot access derived protected method in another module
Summary: Cannot access derived protected method in another module
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-25 06:44 UTC by Andrej Mitrovic
Modified: 2024-12-13 19:04 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2019-06-25 06:44:16 UTC
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..
Comment 1 dlangBugzillaToGithub 2024-12-13 19:04:20 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19594

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB