Skip to content

Commit

Permalink
merge pull 315
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Aug 25, 2011
2 parents 221f942 + 2beebc3 commit e3f1fa2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/mtype.c
Expand Up @@ -1851,17 +1851,6 @@ Expression *Type::noMember(Scope *sc, Expression *e, Identifier *ident)
ident != Id::stringof &&
ident != Id::offsetof)
{
/* See if we should forward to the alias this.
*/
if (sym->aliasthis)
{ /* Rewrite e.ident as:
* e.aliasthis.ident
*/
e = new DotIdExp(e->loc, e, sym->aliasthis->ident);
e = new DotIdExp(e->loc, e, ident);
return e->semantic(sc);
}

/* Look for overloaded opDot() to see if we should forward request
* to it.
*/
Expand Down Expand Up @@ -1898,6 +1887,17 @@ Expression *Type::noMember(Scope *sc, Expression *e, Identifier *ident)
return e;
//return e->semantic(sc);
}

/* See if we should forward to the alias this.
*/
if (sym->aliasthis)
{ /* Rewrite e.ident as:
* e.aliasthis.ident
*/
e = new DotIdExp(e->loc, e, sym->aliasthis->ident);
e = new DotIdExp(e->loc, e, ident);
return e->semantic(sc);
}
}

return Type::dotExp(sc, e, ident);
Expand Down
22 changes: 22 additions & 0 deletions test/runnable/aliasthis.d
Expand Up @@ -475,6 +475,27 @@ void test6369d()
}

/**********************************************/
// 6434

struct Variant6434{}

struct A6434
{
Variant6434 i;
alias i this;

void opDispatch(string name)()
{
}
}

void test6434()
{
A6434 a;
a.weird; // no property 'weird' for type 'VariantN!(maxSize)'
}

/**************************************/

int main()
{
Expand All @@ -495,6 +516,7 @@ int main()
test6369b();
test6369c();
test6369d();
test6434();

printf("Success\n");
return 0;
Expand Down

0 comments on commit e3f1fa2

Please sign in to comment.