October 10, 2014 [Issue 13598] New: enum isPublic(alias e) = __traits(getProtection, e) == "public"; | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13598 Issue ID: 13598 Summary: enum isPublic(alias e) = __traits(getProtection, e) == "public"; Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: major Priority: P1 Component: DMD Assignee: nobody@puremagic.com Reporter: andre@s-e-a-p.de The output of the coding given is: Reference: Child source\test.d(11): Error: class app.Child member childStr is not accessible true source\app.d(8): Error: mixin app.Child.ComponentTemplate!() error instantiating 1.) Althoug childStr is not accessible the text "true" is shown 2.) By uncommenting the line, the output is as expected module test; enum isPublic(alias e) = __traits(getProtection, e) == "public"; template Params(this MyType) { string[] Params() { pragma(msg, "Reference: " ~ MyType.stringof); /*pragma(msg, __traits(getProtection, __traits(getMember, MyType, "childStr")));*/ pragma(msg, isPublic!(__traits(getMember, MyType, "childStr"))); return []; } } mixin template ComponentTemplate() { private enum parameters = Params!(typeof(this)); string[] getParameters() { return parameters; } } class Parent { @property string parentStr(){return "";} } module app; import std.stdio; import test; class Child : Parent { mixin ComponentTemplate; @property string childStr(){return "";} } void main() { auto child = new Child(); writeln(child.getParameters()); } -- |
Copyright © 1999-2021 by the D Language Foundation