On 10/11/2014 12:07 AM, IgorStepanov wrote:
On Friday, 10 October 2014 at 21:25:17 UTC, Walter Bright wrote:

If 'a' and 'b' both contain overloads for function foo, then it should
behave like imports do (which is a bit complex).

Hmm. Now it works as I wrote it DIP pseudo-code:

The pseudo-code doesn't actually specify that the arguments the identifier is being called with are considered at all.

struct A
{
     void foo(string);
     void foo(int);
}

struct B
{
     void foo(double);
}

struct C
{
     A a;
     B b;
     alias a this;
     alias b this;
}

C.foo("test"); //found only one acceptable foo: C.a.foo(string)
C.foo(5);      //1. Check a: found C.a.foo(int);
                //2. Check b: found C.b.foo(double);
                //3. Raise error: C.a.foo(int) vs C.b.foo(double) conflict
C.foo(5.0);    //found only one acceptable foo: C.b.foo(double)

Is it Ok?
...

That is the right behaviour. What happens in this case:

struct A{
    void foo(int);
    void foo(double);
}

struct B
    void foo(string);
}

... // (struct C and calls as yours)



Is it correct that the DIP makes imports at aggregate scope shadow alias this lookups?

Reply via email to