DIP66 - Multiple alias this
via Digitalmars-d
digitalmars-d at puremagic.com
Sun Oct 12 01:36:03 PDT 2014
On Sunday, 12 October 2014 at 04:31:22 UTC, Walter Bright wrote:
> On 10/11/2014 7:23 AM, IgorStepanov wrote:
>> class A
>> {
>> int i;
>> alias i this;
>> }
>>
>> class B
>> {
>> int i;
>> alias i this;
>> }
>>
>> class C
>> {
>> A a;
>> B b;
>> alias a this;
>> alias b this;
>> }
>>
>> void foo(T)(T arg) if(is(T : int))
>> {
>> ...
>> }
>>
>> foo(C()); //Should it pass or not?
>
> There's a rule with imports that if the same symbol is
> reachable via multiple paths through the imports, that it is
> not an ambiguity error. Here, the same type is reachable
> through multiple alias this paths, so by analogy it shouldn't
> be an error.
It's the same type, but different symbols; actual accesses would
be ambiguous. `is(T : int)` shouldn't evaluate to true if `int a
= T.init;` would fail.
More information about the Digitalmars-d
mailing list