UDA: getAttributes does not play well with topleof
d coder
dlang.coder at gmail.com
Tue Dec 18 09:38:43 PST 2012
Greetings
I thought I would be able to use allMembers/getMembers traits to access the
attributes of all the members of a class. But that fails me if some members
of the class are private.
Consider the code pasted below -- I get en error:
B.d(5): Error: class A.Foo member bar is not accessible
And so it seems it is essential that tupleof works with getAttributes,
since tupleof does not care for access protection.
I have filed a bug on Budzilla.
http://d.puremagic.com/issues/show_bug.cgi?id=9178
Regards
- Puneet
module A;
enum Boo;
class Foo {
private @Boo int bar;
}
module B;
void main() {
import A;
Foo foo = new Foo;
static if(__traits(getProtection, __traits(getMember, foo, "bar")) //
<-- can not access foo.bar
== "public")
{
// Check for attribute Boo and proceed
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20121218/6236f63a/attachment.html>
More information about the Digitalmars-d
mailing list