Permalink
Browse files

fix Issue 8123 - alias declaration lookup is broken

  • Loading branch information...
1 parent d5658a5 commit 76543ef60f3b871612ddc0c87999859f427ba6f9 @9rnsr 9rnsr committed May 20, 2012
Showing with 49 additions and 15 deletions.
  1. +15 −13 src/declaration.c
  2. +2 −0 src/declaration.h
  3. +32 −2 test/runnable/declaration.d
View
28 src/declaration.c
@@ -122,6 +122,18 @@ void Declaration::checkModify(Loc loc, Scope *sc, Type *t)
}
#endif
+Dsymbol *Declaration::search(Loc loc, Identifier *ident, int flags)
+{
+ Dsymbol *s = Dsymbol::search(loc, ident, flags);
+ if (!s && type)
+ {
+ s = type->toDsymbol(NULL);
+ if (s)
+ s = s->search(loc, ident, flags);
+ }
+ return s;
+}
+
/********************************* TupleDeclaration ****************************/
@@ -497,18 +509,6 @@ void AliasDeclaration::semantic(Scope *sc)
else if (t)
{
type = t->semantic(loc, sc);
-
- /* If type is class or struct, convert to symbol.
- * See bugzilla 6475.
- */
- s = type->toDsymbol(sc);
- if (s
-#if DMDV2
- && ((s->getType() && type->equals(s->getType())) || s->isEnumMember())
-#endif
- )
- goto L2;
-
//printf("\talias resolved to type %s\n", type->toChars());
}
if (overnext)
@@ -617,7 +617,9 @@ const char *AliasDeclaration::kind()
Type *AliasDeclaration::getType()
{
- return type;
+ if (type)
+ return type;
+ return toAlias()->getType();
}
Dsymbol *AliasDeclaration::toAlias()
View
2 src/declaration.h
@@ -133,6 +133,8 @@ struct Declaration : Dsymbol
unsigned size(Loc loc);
void checkModify(Loc loc, Scope *sc, Type *t);
+ Dsymbol *search(Loc loc, Identifier *ident, int flags);
+
void emitComment(Scope *sc);
void toJsonBuffer(OutBuffer *buf);
void toDocBuffer(OutBuffer *buf);
View
34 test/runnable/declaration.d
@@ -11,8 +11,13 @@ class Foo6475(Value)
void test6475()
{
- alias Foo6475!(int) C2;
- alias C2.T1!0 a1;
+ alias Foo6475!(int) C1;
+ alias C1.T1!0 X1;
+ static assert(is(X1 == int));
+
+ alias const(Foo6475!(int)) C2;
+ alias C2.T1!0 X2;
+ static assert(is(X2 == int));
}
/***************************************************/
@@ -37,11 +42,36 @@ void test7239()
}
/***************************************************/
+// 8123
+
+void test8123()
+{
+ struct S { }
+
+ struct AS
+ {
+ alias S Alias;
+ }
+
+ struct Wrapper
+ {
+ AS as;
+ }
+
+ Wrapper w;
+ static assert(is(typeof(w.as).Alias == S)); // fail
+ static assert(is(AS.Alias == S)); // ok
+ static assert(is(typeof(w.as) == AS)); // ok
+ static assert(is(typeof(w.as).Alias == AS.Alias)); // fail
+}
+
+/***************************************************/
int main()
{
test6475();
test7239();
+ test8123();
printf("Success\n");
return 0;

0 comments on commit 76543ef

Please sign in to comment.