D-Programming-Language/dmd — pull request #3998 by IgorStepanov (2014-09-16 11:40:59+00:00)
Title: [tdpl] Multiple alias this

This PR introduces multiple alias this.
The old alias this implemenation doesn't imply alias this conflicts.
All alias this-es in old implementation are serializable: compiler successively applies a, a->aliasthis, a->aliasthis->aliasthis while right expression is not found.

This implementation allows tree of alias this subtypes.
Type can has a direct "alias this"-es and "alias this"-es, inherited from base classes/interfaces. Thus, there can be conflict between several matching "alias this"-es.
In common case compile should raise error if several "alias this"-es have found.
However, in the next situation conflict can be resolved:
```
struct Test9a
{
int a;
alias a this;
}

struct Test9b
{
int a;
alias a this;
}

struct Test9
{
Test9a a;
Test9b b;
int c;
alias a this;
alias b this;
alias c this;
}

void test()
{
Test9 t9;
int a = t9;
}
```

When we try to cast `Test9` to int we can find several variants: `t9.a.a`, `t9.b.a`, `t9.c`.
However, `t9.c` is preferred, because `Test9` author is explicitly pointed out that `Test9` should be converted to `int` through `c` field. This magic works only if we have exact match. `short a = t9;` causes error.

This PR have a one limitation: it doesn't support multiple tuple alias this. It don't clearly understand how them should works. Multiple tuple alias this can be implemented in future in a separate PR.