D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10267 - Access checks should be relaxed in some contexts
Summary: Access checks should be relaxed in some contexts
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks: 10258
  Show dependency treegraph
 
Reported: 2013-06-04 08:57 UTC by Andrej Mitrovic
Modified: 2021-05-11 09:06 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2013-06-04 08:57:03 UTC
Currently we can't filter out function overloads which are non-accessible. As soon as one of a functions overloads is inaccessible the getOverloads trait will fail, essentially making the getProtection trait also unusable. For example:

foo.d:

-----
module foo;

struct S
{
    private void x(int) { }     // private overload
    public void x(float) { }   // public overload
}
-----

-----
module test;
import foo;

void main()
{
    foreach (member; __traits(allMembers, S))
    {
        // Error: struct foo.S member x is not accessible
        foreach (overload; __traits(getOverloads, S, member))
        {
            // too late, already errored out
            static if (__traits(getProtection, overload) == "public")
            {
                // ... do something if accessible
            }
        }
    }
}
-----

Some comments:

https://github.com/D-Programming-Language/phobos/pull/1331#issuecomment-18915427
https://github.com/D-Programming-Language/phobos/pull/1331#issuecomment-18918513
Comment 1 RazvanN 2021-05-11 09:06:28 UTC
This compiles in todays compiler. Closing as w4m.