This is an extremely simplified version of my real code (cl4d) where these 3 parts are distributed among several files (and thus heavily depend on the build order). ---- class Collection(T) { } ICollection c; alias Collection!int ICollection; fwdref2.d(4): Error: forward reference to 'Collection!(int)' fwdref2.d(4): Error: ICollection is used as a type ---- Putting ICollection c; at the end makes it compile.
error occurs at mtype.c:5542 if (t->ty == Tinstance && t != this && !t->deco) { error(loc, "forward reference to '%s'", t->toChars()); return; } This is also true if ICollection is referenced like this: void foo(ICollection c) { }
A test with if (t->ty == Tinstance && t != this && !t->deco) { //error(loc, "forward reference to '%s'", t->toChars()); //return; t = t->semantic(loc, sc); } solved this issue. Don't know if that causes other problems though.
This patch seems a bit more generic and solved a similar issue for me. It also works for your code: Index: declaration.c =================================================================== --- declaration.c (revision 576) +++ declaration.c (working copy) @@ -594,6 +594,9 @@ { error("recursive alias declaration"); aliassym = new TypedefDeclaration(loc, ident, Type::terror, NULL); } + else if (!aliassym && scope) + semantic(scope); + Dsymbol *s = aliassym ? aliassym->toAlias() : this; return s; }
Great! Also seems to solve http://d.puremagic.com/issues/show_bug.cgi?id=4267
And this one: http://d.puremagic.com/issues/show_bug.cgi?id=3679
http://www.dsource.org/projects/dmd/changeset/607
Fixed DMD1.063 and 2.048.
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル