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.
Comment #1 by hoganmeier — 2010-07-24T12:05:53Z
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)
{
}
Comment #2 by hoganmeier — 2010-07-25T14:04:50Z
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.
Comment #3 by r.sagitario — 2010-07-26T00:32:51Z
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;
}