[Issue 9546] New: getProtection trait does not work with mixin or getMember

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 19 20:37:51 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9546

           Summary: getProtection trait does not work with mixin or
                    getMember
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-02-19 20:37:50 PST ---
/imorts/a.d:
---------------------------
module imports.a;

class S
{
    private int privA;
    protected int protA;
    package int packA;
}
---------------------------


/test.d:
---------------------------
import imports.a;

void main()
{
    S s;
    static assert(__traits(getProtection, s.privA) == "private");
    static assert(__traits(getProtection, s.protA) == "protected");
    static assert(__traits(getProtection, s.packA) == "package");

    /** NG - symbols not accessible */
    static assert(__traits(getProtection, mixin("s.privA")) == "private");
    static assert(__traits(getProtection, mixin("s.protA")) == "protected");
    static assert(__traits(getProtection, mixin("s.packA")) == "package");

    /** NG - symbols not accessible */
    static assert(__traits(getProtection, 
                  __traits(getMember, s, "privA")) == "private");
    static assert(__traits(getProtection, 
                  __traits(getMember, s, "protA")) == "protected");
    static assert(__traits(getProtection, 
                  __traits(getMember, s, "packA")) == "package");
}
---------------------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list