Why can we not use __traits across protection?
Steven Schveighoffer
schveiguy at gmail.com
Mon Apr 15 14:55:36 UTC 2019
On 4/3/19 5:19 AM, Atila Neves wrote:
> On Tuesday, 2 April 2019 at 14:56:38 UTC, Alex wrote:
>> Module X:
>>
>> class x
>> {
>> private int x;
>> }
>>
>> Module Y:
>>
>> import X;
>>
>> moduleName!(x.x);
>>
>> or
>>
>> __traits(getProtection, x.x);
>>
>> Deprecation: `X.x.x.x` is not visible from module `Y`
>> Error: class `X.x.x` member `x` is not accessible
>>
>> My use case is a little more complicated but I have two issues.
>
> __traits(getProtection, __traits(getMember, x, "x")) works. You just
> can't spell "x.x" anywhere.
>
So this is quite unintuitive. The compiler should realize here you are
just checking protection, and forego the protection check on the
expression. I.e. there should be a special exception to visibility
checking inside __traits(getProtection, ...).
-Steve
More information about the Digitalmars-d
mailing list