+ /// <summary>
+ /// Represents an "unbound generic type", ie. typeof (Foo<>).
+ /// See 14.5.11.
+ /// </summary>
+ public class UnboundTypeExpression : TypeLookupExpression {
+ public UnboundTypeExpression (string name)
+ : base (name)
+ { }
+ }
+
+ public class TypeAliasExpression : TypeExpr, IAlias {
+ TypeExpr texpr;
+ TypeArguments args;
+ string name;
+
+ public TypeAliasExpression (TypeExpr texpr, TypeArguments args, Location l)
+ {
+ this.texpr = texpr;
+ this.args = args;
+ loc = texpr.Location;
+
+ eclass = ExprClass.Type;
+ if (args != null)
+ name = texpr.Name + "<" + args.ToString () + ">";
+ else
+ name = texpr.Name;
+ }
+
+ public override string Name {
+ get { return name; }
+ }
+
+ public override TypeExpr DoResolveAsTypeStep (EmitContext ec)
+ {
+ Type type = texpr.ResolveType (ec);
+ if (type == null)
+ return null;
+
+ int num_args = TypeManager.GetNumberOfTypeArguments (type);
+
+ if (args != null) {
+ if (num_args == 0) {
+ Report.Error (308, loc,
+ "The non-generic type `{0}' cannot " +
+ "be used with type arguments.",
+ TypeManager.CSharpName (type));
+ return null;
+ }
+
+ ConstructedType ctype = new ConstructedType (type, args, loc);
+ return ctype.ResolveAsTypeTerminal (ec);
+ } else if (num_args > 0) {
+ Report.Error (305, loc,
+ "Using the generic type `{0}' " +
+ "requires {1} type arguments",
+ TypeManager.GetFullName (type), num_args);
+ return null;
+ }
+
+ return new TypeExpression (type, loc);
+ }
+
+ public override Type ResolveType (EmitContext ec)
+ {
+ TypeExpr t = ResolveAsTypeTerminal (ec);
+ if (t == null)
+ return null;
+
+ type = t.ResolveType (ec);
+ return type;
+ }
+
+ public override bool CheckAccessLevel (DeclSpace ds)
+ {
+ return texpr.CheckAccessLevel (ds);
+ }
+
+ public override bool AsAccessible (DeclSpace ds, int flags)
+ {
+ return texpr.AsAccessible (ds, flags);
+ }
+
+ public override bool IsClass {
+ get { return texpr.IsClass; }
+ }
+
+ public override bool IsValueType {
+ get { return texpr.IsValueType; }
+ }
+
+ public override bool IsInterface {
+ get { return texpr.IsInterface; }
+ }
+
+ public override bool IsSealed {
+ get { return texpr.IsSealed; }
+ }
+
+ public override bool IsAttribute {
+ get { return texpr.IsAttribute; }
+ }
+ }
+