2008-11-18 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Tue, 18 Nov 2008 14:03:06 +0000 (14:03 -0000)
committerMarek Safar <marek.safar@gmail.com>
Tue, 18 Nov 2008 14:03:06 +0000 (14:03 -0000)
* generic.cs, iterators.cs, anonymous.cs, nullable.cs, ecore.cs,
expression.cs, namespace.cs, generic-mcs.cs, class.cs: Small cleanup
of ConstructedType expression, renamed to GenericTypeExpr.

svn path=/trunk/mcs/; revision=119153

mcs/mcs/ChangeLog
mcs/mcs/anonymous.cs
mcs/mcs/class.cs
mcs/mcs/ecore.cs
mcs/mcs/expression.cs
mcs/mcs/generic-mcs.cs
mcs/mcs/generic.cs
mcs/mcs/iterators.cs
mcs/mcs/namespace.cs
mcs/mcs/nullable.cs

index a084f62e56a8412870271ab051812c3385fcda80..c3adbf821e43f741259b82f701e5f25c508cb4a9 100644 (file)
@@ -1,3 +1,9 @@
+2008-11-18  Marek Safar  <marek.safar@gmail.com>
+
+       * generic.cs, iterators.cs, anonymous.cs, nullable.cs, ecore.cs,
+       expression.cs, namespace.cs, generic-mcs.cs, class.cs: Small cleanup
+       of ConstructedType expression, renamed to GenericTypeExpr.
+
 2008-11-17  Marek Safar  <marek.safar@gmail.com>
 
        A fix for bug #445303
index 7043585f15df39bf8dbc78453ffcfbda85158f7c..6bd1bc43f583ddc78169ef1456b0fb7e7f15fe26 100644 (file)
@@ -269,15 +269,18 @@ namespace Mono.CSharp {
                                        ec.CurrentAnonymousMethod.Storey.TypeParameters :
                                        ec.GenericDeclContainer.TypeParameters;
 
-                               if (tparams.Length != CountTypeParameters) {
-                                       TypeParameter [] full = new TypeParameter [CountTypeParameters];
-                                       DeclSpace parent = ec.DeclContainer.Parent;
-                                       parent.CurrentTypeParameters.CopyTo (full, 0);
-                                       tparams.CopyTo (full, parent.CountTypeParameters);
-                                       tparams = full;
+                               TypeArguments targs = new TypeArguments (Location);
+
+                               if (tparams.Length < CountTypeParameters) {
+                                       TypeParameter[] parent_tparams = ec.DeclContainer.Parent.CurrentTypeParameters;
+                                       for (int i = 0; i < parent_tparams.Length; ++i)
+                                               targs.Add (new TypeParameterExpr (parent_tparams[i], Location));
                                }
+                               
+                               for (int i = 0; i < tparams.Length; ++i)
+                                       targs.Add (new TypeParameterExpr (tparams[i], Location));
 
-                               storey_type_expr = new ConstructedType (TypeBuilder, tparams, Location);
+                               storey_type_expr = new GenericTypeExpr (TypeBuilder, targs, Location);
                        } else {
                                storey_type_expr = new TypeExpression (TypeBuilder, Location);
                        }
@@ -1731,7 +1734,7 @@ namespace Mono.CSharp {
                        ToplevelBlock equals_block = new ToplevelBlock (equals.Parameters, loc);
                        TypeExpr current_type;
                        if (IsGeneric)
-                               current_type = new ConstructedType (TypeBuilder, TypeParameters, loc);
+                               current_type = new GenericTypeExpr (this, loc);
                        else
                                current_type = new TypeExpression (TypeBuilder, loc);
 
index d5938e3de744d22160ac8f640c7a035f3380680f..f68cac5ad8bba0c03a223ae89a71f1343852a84d 100644 (file)
@@ -1177,7 +1177,9 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       current_type = new ConstructedType (TypeBuilder, TypeParameters, Location);
+                       // TODO: Very strange, why not simple make generic type from
+                       // current type parameters
+                       current_type = new GenericTypeExpr (this, Location);
                        current_type = current_type.ResolveAsTypeTerminal (this, false);
                        if (current_type == null) {
                                error = true;
@@ -1272,7 +1274,7 @@ namespace Mono.CSharp {
                                                AttributeTester.Report_ObsoleteMessage (
                                                        oa, iface.GetSignatureForError (), Location);
 
-                                       ConstructedType ct = iface as ConstructedType;
+                                       GenericTypeExpr ct = iface as GenericTypeExpr;
                                        if ((ct != null) && !ct.CheckConstraints (this))
                                                return false;
                                }
@@ -1283,7 +1285,7 @@ namespace Mono.CSharp {
                                if (obsolete_attr != null && !IsInObsoleteScope)
                                        AttributeTester.Report_ObsoleteMessage (obsolete_attr, base_type.GetSignatureForError (), Location);
 
-                               ConstructedType ct = base_type as ConstructedType;
+                               GenericTypeExpr ct = base_type as GenericTypeExpr;
                                if ((ct != null) && !ct.CheckConstraints (this))
                                        return false;
                                
index 8788d7e6557770bd83003520ad567e778a251063..eb51da851ffdb1b159744bf92602ed2e976ff0a8 100644 (file)
@@ -282,7 +282,7 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       ConstructedType ct = te as ConstructedType;
+                       GenericTypeExpr ct = te as GenericTypeExpr;
                        if (ct != null) {
                                // Skip constrains check for overrides and explicit implementations
                                // TODO: they should use different overload
@@ -576,7 +576,7 @@ namespace Mono.CSharp {
                        if (e.eclass == ExprClass.Invalid)
                                throw new Exception ("Expression " + e + " ExprClass is Invalid after resolve");
 
-                       if ((e.type == null) && !(e is ConstructedType))
+                       if ((e.type == null) && !(e is GenericTypeExpr))
                                throw new Exception ("Expression " + e + " did not set its type after Resolve");
 
                        return e;
@@ -1182,6 +1182,12 @@ namespace Mono.CSharp {
                        }
                }
 
+               public void Error_ExpressionCannotBeGeneric (Location loc)
+               {
+                       Report.Error (307, loc, "The {0} `{1}' cannot be used with type arguments",
+                               ExprClassName, GetSignatureForError ());
+               }
+
                //
                // Converts `source' to an int, uint, long or ulong.
                //
@@ -2462,7 +2468,7 @@ namespace Mono.CSharp {
                                        if (targs != null)
                                                new_args.Add (targs);
 
-                                       return new ConstructedType (t, new_args, loc);
+                                       return new GenericTypeExpr (t, new_args, loc);
                                }
                        }
 
@@ -2487,7 +2493,7 @@ namespace Mono.CSharp {
                                        return nested.ResolveAsTypeStep (ec, false);
 
                                if (targs != null) {
-                                       ConstructedType ct = new ConstructedType (fne, targs, loc);
+                                       GenericTypeExpr ct = new GenericTypeExpr (fne.Type, targs, loc);
                                        return ct.ResolveAsTypeStep (ec, false);
                                }
 
@@ -2529,7 +2535,7 @@ namespace Mono.CSharp {
                        if (targs != null) {
                                FullNamedExpression retval = ec.DeclContainer.LookupNamespaceOrType (SimpleName.RemoveGenericArity (Name), loc, true);
                                if (retval != null) {
-                                       Namespace.Error_TypeArgumentsCannotBeUsed (retval.Type, loc);
+                                       Namespace.Error_TypeArgumentsCannotBeUsed (retval, loc);
                                        return;
                                }
                        }
@@ -2603,13 +2609,6 @@ namespace Mono.CSharp {
                        if (current_block != null){
                                LocalInfo vi = current_block.GetLocalInfo (Name);
                                if (vi != null){
-                                       if (targs != null) {
-                                               Report.Error (307, loc,
-                                                             "The variable `{0}' cannot be used with type arguments",
-                                                             Name);
-                                               return null;
-                                       }
-
                                        LocalVariableReference var = new LocalVariableReference (ec.CurrentBlock, Name, loc);
                                        if (right_side != null) {
                                                return var.ResolveLValue (ec, right_side, loc);
@@ -2621,25 +2620,14 @@ namespace Mono.CSharp {
                                        }
                                }
 
-                               ParameterReference pref = current_block.Toplevel.GetParameterReference (Name, loc);
-                               if (pref != null) {
-                                       if (targs != null) {
-                                               Report.Error (307, loc,
-                                                             "The variable `{0}' cannot be used with type arguments",
-                                                             Name);
-                                               return null;
-                                       }
-
-                                       if (right_side != null)
-                                               return pref.ResolveLValue (ec, right_side, loc);
-                                       else
-                                               return pref.Resolve (ec);
-                               }
+                               Expression expr = current_block.Toplevel.GetParameterReference (Name, loc);
+                               if (expr == null)
+                                       expr = current_block.Toplevel.GetTransparentIdentifier (Name);
 
-                               Expression expr = current_block.Toplevel.GetTransparentIdentifier (Name);
                                if (expr != null) {
                                        if (right_side != null)
                                                return expr.ResolveLValue (ec, right_side, loc);
+
                                        return expr.Resolve (ec);
                                }
                        }
@@ -2721,7 +2709,7 @@ namespace Mono.CSharp {
                                if (targs == null)
                                        return e;
 
-                               ConstructedType ct = new ConstructedType (
+                               GenericTypeExpr ct = new GenericTypeExpr (
                                        e.Type, targs, loc);
                                return ct.ResolveAsTypeStep (ec, false);
                        }
@@ -3148,7 +3136,7 @@ namespace Mono.CSharp {
                                        AttributeTester.Report_ObsoleteMessage (oa, left.GetSignatureForError (), loc);
                                }
 
-                               ConstructedType ct = left as ConstructedType;
+                               GenericTypeExpr ct = left as GenericTypeExpr;
                                if (ct != null && !ct.CheckConstraints (ec))
                                        return null;
                                //
index 2ac8cc790b57f9f8199c10b5dfa1869c9fbb01d5..9d64a123d52b29799dac139ba05fb8a5cb65c63a 100644 (file)
@@ -7301,8 +7301,6 @@ namespace Mono.CSharp {
                        this.expr = expr;
                }
 
-               // TODO: this method has very poor performace for Enum fields and
-               // probably for other constants as well
                Expression DoResolve (EmitContext ec, Expression right_side)
                {
                        if (type != null)
@@ -7325,16 +7323,15 @@ namespace Mono.CSharp {
 
                        string LookupIdentifier = MemberName.MakeName (Name, targs);
 
-                       if (expr_resolved is Namespace) {
-                               Namespace ns = (Namespace) expr_resolved;
+                       Namespace ns = expr_resolved as Namespace;
+                       if (ns != null) {
                                FullNamedExpression retval = ns.Lookup (ec.DeclContainer, LookupIdentifier, loc);
-#if GMCS_SOURCE
-                               if ((retval != null) && (targs != null))
-                                       retval = new ConstructedType (retval, targs, loc).ResolveAsTypeStep (ec, false);
-#endif
 
                                if (retval == null)
-                                       ns.Error_NamespaceDoesNotExist (ec.DeclContainer, loc, Name);
+                                       ns.Error_NamespaceDoesNotExist (ec.DeclContainer, loc, LookupIdentifier);
+                               else if (targs != null)
+                                       retval = new GenericTypeExpr (retval.Type, targs, loc).ResolveAsTypeStep (ec, false);
+
                                return retval;
                        }
 
@@ -7410,7 +7407,7 @@ namespace Mono.CSharp {
                                }
 
 #if GMCS_SOURCE
-                               ConstructedType ct = expr_resolved as ConstructedType;
+                               GenericTypeExpr ct = expr_resolved as GenericTypeExpr;
                                if (ct != null) {
                                        //
                                        // When looking up a nested type in a generic instance
@@ -7419,7 +7416,7 @@ namespace Mono.CSharp {
                                        //
                                        // See gtest-172-lib.cs and gtest-172.cs for an example.
                                        //
-                                       ct = new ConstructedType (
+                                       ct = new GenericTypeExpr (
                                                member_lookup.Type, ct.TypeArguments, loc);
 
                                        return ct.ResolveAsTypeStep (ec, false);
@@ -7471,26 +7468,26 @@ namespace Mono.CSharp {
 
                public FullNamedExpression ResolveNamespaceOrType (IResolveContext rc, bool silent)
                {
-                       FullNamedExpression new_expr = expr.ResolveAsTypeStep (rc, silent);
+                       FullNamedExpression expr_resolved = expr.ResolveAsTypeStep (rc, silent);
 
-                       if (new_expr == null)
+                       if (expr_resolved == null)
                                return null;
 
                        string LookupIdentifier = MemberName.MakeName (Name, targs);
 
-                       if (new_expr is Namespace) {
-                               Namespace ns = (Namespace) new_expr;
+                       Namespace ns = expr_resolved as Namespace;
+                       if (ns != null) {
                                FullNamedExpression retval = ns.Lookup (rc.DeclContainer, LookupIdentifier, loc);
-#if GMCS_SOURCE
-                               if ((retval != null) && (targs != null))
-                                       retval = new ConstructedType (retval, targs, loc).ResolveAsTypeStep (rc, false);
-#endif
-                               if (!silent && retval == null)
+
+                               if (retval == null && !silent)
                                        ns.Error_NamespaceDoesNotExist (rc.DeclContainer, loc, LookupIdentifier);
+                               else if (targs != null)
+                                       retval = new GenericTypeExpr (retval.Type, targs, loc).ResolveAsTypeStep (rc, silent);
+
                                return retval;
                        }
 
-                       TypeExpr tnew_expr = new_expr.ResolveAsTypeTerminal (rc, false);
+                       TypeExpr tnew_expr = expr_resolved.ResolveAsTypeTerminal (rc, false);
                        if (tnew_expr == null)
                                return null;
 
@@ -7508,7 +7505,7 @@ namespace Mono.CSharp {
                                if (silent)
                                        return null;
 
-                               Error_IdentifierNotFound (rc, new_expr, LookupIdentifier);
+                               Error_IdentifierNotFound (rc, expr_resolved, LookupIdentifier);
                                return null;
                        }
 
@@ -7535,7 +7532,7 @@ namespace Mono.CSharp {
                        }
 
                        if (the_args != null) {
-                               ConstructedType ctype = new ConstructedType (texpr.Type, the_args, loc);
+                               GenericTypeExpr ctype = new GenericTypeExpr (texpr.Type, the_args, loc);
                                return ctype.ResolveAsTypeStep (rc, false);
                        }
 #endif
@@ -7554,7 +7551,7 @@ namespace Mono.CSharp {
                                if (expr_type == null)
                                        return;
 
-                               Namespace.Error_TypeArgumentsCannotBeUsed (expr_type.Type, loc);
+                               Namespace.Error_TypeArgumentsCannotBeUsed (expr_type, loc);
                                return;
                        }
 
@@ -9732,7 +9729,7 @@ namespace Mono.CSharp {
                        if (anonymous_type == null)
                                return null;
 
-                       ConstructedType te = new ConstructedType (anonymous_type.TypeBuilder,
+                       GenericTypeExpr te = new GenericTypeExpr (anonymous_type.TypeBuilder,
                                new TypeArguments (loc, t_args), loc);
 
                        return new New (te, arguments, loc).Resolve (ec);
index 2505cba9993fa190bd090ce08e0bc6c8a91f449f..6da073a861ec0cd5794d4ba2fccd60f5fe1b25eb 100644 (file)
@@ -209,19 +209,14 @@ namespace Mono.CSharp
                }
        }
 
-       public class ConstructedType : TypeExpr
+       public class GenericTypeExpr : TypeExpr
        {
-               public ConstructedType (FullNamedExpression fname, TypeArguments args, Location l)
+               public GenericTypeExpr (DeclSpace t, Location l)
                {
                        throw new NotImplementedException ();
                }
 
-               public ConstructedType (Type t, TypeParameter[] type_params, Location l)
-               {
-                       throw new NotImplementedException ();
-               }
-
-               public ConstructedType (Type t, TypeArguments args, Location l)
+               public GenericTypeExpr (Type t, TypeArguments args, Location l)
                {
                        throw new NotImplementedException ();
                }
index 52ea9becac91f2a267948272956d555c059b1574..5dcd5915c098721f4a99411b399bda7e917fbd41 100644 (file)
@@ -231,12 +231,9 @@ namespace Mono.CSharp {
                                }
 
                                TypeExpr expr;
-                               ConstructedType cexpr = fn as ConstructedType;
+                               GenericTypeExpr cexpr = fn as GenericTypeExpr;
                                if (cexpr != null) {
-                                       if (!cexpr.ResolveConstructedType (ec))
-                                               return false;
-
-                                       expr = cexpr;
+                                       expr = cexpr.ResolveAsBaseTerminal (ec, false);
                                } else
                                        expr = ((Expression) obj).ResolveAsTypeTerminal (ec, false);
 
@@ -419,7 +416,7 @@ namespace Mono.CSharp {
                        resolved_types = true;
 
                        foreach (object obj in constraints) {
-                               ConstructedType cexpr = obj as ConstructedType;
+                               GenericTypeExpr cexpr = obj as GenericTypeExpr;
                                if (cexpr == null)
                                        continue;
 
@@ -1229,40 +1226,29 @@ namespace Mono.CSharp {
        }
 
        /// <summary>
-       ///   An instantiation of a generic type.
+       ///   A reference expression to generic type
        /// </summary>  
-       public class ConstructedType : TypeExpr {
-               FullNamedExpression name;
+       class GenericTypeExpr : TypeExpr
+       {
                TypeArguments args;
-               Type[] gen_params, atypes;
-               Type gt;
+               Type[] gen_params;      // TODO: Waiting for constrains check cleanup
+               Type open_type;
 
-               /// <summary>
-               ///   Instantiate the generic type `fname' with the type arguments `args'.
-               /// </summary>          
-               public ConstructedType (FullNamedExpression fname, TypeArguments args, Location l)
-               {
-                       loc = l;
-                       this.name = fname;
-                       this.args = args;
-
-                       eclass = ExprClass.Type;
-               }
-
-               /// <summary>
-               ///   This is used to construct the `this' type inside a generic type definition.
-               /// </summary>
-               public ConstructedType (Type t, TypeParameter[] type_params, Location l)
+               //
+               // Should be carefully used only with defined generic containers. Type parameters
+               // can be used as type arguments in this case.
+               //
+               // TODO: This could be GenericTypeExpr specialization
+               //
+               public GenericTypeExpr (DeclSpace gType, Location l)
                {
-                       gt = t.GetGenericTypeDefinition ();
+                       open_type = gType.TypeBuilder.GetGenericTypeDefinition ();
 
                        args = new TypeArguments (l);
-                       foreach (TypeParameter type_param in type_params)
+                       foreach (TypeParameter type_param in gType.TypeParameters)
                                args.Add (new TypeParameterExpr (type_param, l));
 
                        this.loc = l;
-                       this.name = new TypeExpression (gt, l);
-                       eclass = ExprClass.Type;
                }
 
                /// <summary>
@@ -1270,11 +1256,12 @@ namespace Mono.CSharp {
                ///   Use this constructor if you already know the fully resolved
                ///   generic type.
                /// </summary>          
-               public ConstructedType (Type t, TypeArguments args, Location l)
-                       : this ((FullNamedExpression)null, args, l)
+               public GenericTypeExpr (Type t, TypeArguments args, Location l)
                {
-                       gt = t.GetGenericTypeDefinition ();
-                       this.name = new TypeExpression (gt, l);
+                       open_type = t.GetGenericTypeDefinition ();
+
+                       loc = l;
+                       this.args = args;
                }
 
                public TypeArguments TypeArguments {
@@ -1288,9 +1275,22 @@ namespace Mono.CSharp {
 
                protected override TypeExpr DoResolveAsTypeStep (IResolveContext ec)
                {
-                       if (!ResolveConstructedType (ec))
+                       if (!args.Resolve (ec))
+                               return null;
+
+                       gen_params = open_type.GetGenericArguments ();
+                       Type[] atypes = args.Arguments;
+                       
+                       if (atypes.Length != gen_params.Length) {
+                               Namespace.Error_InvalidNumberOfTypeArguments (open_type, loc);
                                return null;
+                       }
 
+                       //
+                       // Now bind the parameters
+                       //
+                       type = open_type.MakeGenericType (atypes);
+                       eclass = ExprClass.Type;
                        return this;
                }
 
@@ -1300,102 +1300,43 @@ namespace Mono.CSharp {
                /// </summary>
                public bool CheckConstraints (IResolveContext ec)
                {
-                       return ConstraintChecker.CheckConstraints (ec, gt, gen_params, atypes, loc);
-               }
-
-               /// <summary>
-               ///   Resolve the constructed type, but don't check the constraints.
-               /// </summary>
-               public bool ResolveConstructedType (IResolveContext ec)
-               {
-                       if (type != null)
-                               return true;
-                       // If we already know the fully resolved generic type.
-                       if (gt != null)
-                               return DoResolveType (ec);
-
-                       int num_args;
-                       Type t = name.Type;
-
-                       if (t == null) {
-                               Report.Error (246, loc, "Cannot find type `{0}'<...>", GetSignatureForError ());
-                               return false;
-                       }
-
-                       num_args = TypeManager.GetNumberOfTypeArguments (t);
-                       if (num_args == 0) {
-                               Report.Error (308, loc,
-                                             "The non-generic type `{0}' cannot " +
-                                             "be used with type arguments.",
-                                             TypeManager.CSharpName (t));
-                               return false;
-                       }
-
-                       gt = t.GetGenericTypeDefinition ();
-                       return DoResolveType (ec);
-               }
-
-               bool DoResolveType (IResolveContext ec)
-               {
-                       //
-                       // Resolve the arguments.
-                       //
-                       if (args.Resolve (ec) == false)
-                               return false;
-
-                       gen_params = gt.GetGenericArguments ();
-                       atypes = args.Arguments;
-
-                       if (atypes.Length != gen_params.Length) {
-                               Report.Error (305, loc,
-                                             "Using the generic type `{0}' " +
-                                             "requires {1} type arguments",
-                                             TypeManager.CSharpName (gt),
-                                             gen_params.Length.ToString ());
-                               return false;
-                       }
-
-                       //
-                       // Now bind the parameters.
-                       //
-                       type = gt.MakeGenericType (atypes);
-                       return true;
+                       return ConstraintChecker.CheckConstraints (ec, open_type, gen_params, args.Arguments, loc);
                }
 
                public override bool CheckAccessLevel (DeclSpace ds)
                {
-                       return ds.CheckAccessLevel (gt);
+                       return ds.CheckAccessLevel (open_type);
                }
 
                public override bool AsAccessible (DeclSpace ds)
                {
-                       foreach (Type t in atypes) {
+                       foreach (Type t in args.Arguments) {
                                if (!ds.IsAccessibleAs (t))
                                        return false;
                        }
 
-                       return ds.IsAccessibleAs (gt);
+                       return ds.IsAccessibleAs (open_type);
                }
 
                public override bool IsClass {
-                       get { return gt.IsClass; }
+                       get { return open_type.IsClass; }
                }
 
                public override bool IsValueType {
-                       get { return gt.IsValueType; }
+                       get { return open_type.IsValueType; }
                }
 
                public override bool IsInterface {
-                       get { return gt.IsInterface; }
+                       get { return open_type.IsInterface; }
                }
 
                public override bool IsSealed {
-                       get { return gt.IsSealed; }
+                       get { return open_type.IsSealed; }
                }
 
                public override bool Equals (object obj)
                {
-                       ConstructedType cobj = obj as ConstructedType;
+                       GenericTypeExpr cobj = obj as GenericTypeExpr;
                        if (cobj == null)
                                return false;
 
@@ -1556,7 +1497,7 @@ namespace Mono.CSharp {
                                        new_args.Add (new TypeExpression (t, loc));
                                }
 
-                               TypeExpr ct = new ConstructedType (ctype, new_args, loc);
+                               TypeExpr ct = new GenericTypeExpr (ctype, new_args, loc);
                                if (ct.ResolveAsTypeStep (ec, false) == null)
                                        return false;
                                ctype = ct.Type;
index 9c7920899ccd3b7d7a9682b36928b830c587bac4..73a3e861a3c349df0a1a410233e2bea00b0834da 100644 (file)
@@ -432,7 +432,7 @@ namespace Mono.CSharp {
                                list.Add (enumerable_type);
 
 #if GMCS_SOURCE
-                               generic_enumerable_type = new ConstructedType (
+                               generic_enumerable_type = new GenericTypeExpr (
                                        TypeManager.generic_ienumerable_type,
                                        generic_args, Location);
                                list.Add (generic_enumerable_type);
@@ -446,7 +446,7 @@ namespace Mono.CSharp {
                        list.Add (new TypeExpression (TypeManager.idisposable_type, Location));
 
 #if GMCS_SOURCE
-                       generic_enumerator_type = new ConstructedType (
+                       generic_enumerator_type = new GenericTypeExpr (
                                TypeManager.generic_ienumerator_type,
                                generic_args, Location);
                        list.Add (generic_enumerator_type);
index 451ba0bf1c61b7bfd4a68d2c267edb7a1cdc6cde..8cec4277e263ab0ffac97fac22e738d3528f6b39 100644 (file)
@@ -366,7 +366,7 @@ namespace Mono.CSharp {
                        if (name.IndexOf ('`') > 0) {
                                FullNamedExpression retval = Lookup (ds, SimpleName.RemoveGenericArity (name), loc);
                                if (retval != null) {
-                                       Error_TypeArgumentsCannotBeUsed (retval.Type, loc);
+                                       Error_TypeArgumentsCannotBeUsed (retval, loc);
                                        return;
                                }
                        } else {
@@ -388,10 +388,14 @@ namespace Mono.CSharp {
                                TypeManager.CSharpName(t), TypeManager.GetNumberOfTypeArguments(t).ToString());
                }
 
-               public static void Error_TypeArgumentsCannotBeUsed (Type t, Location loc)
+               public static void Error_TypeArgumentsCannotBeUsed (FullNamedExpression expr, Location loc)
                {
-                       Report.SymbolRelatedToPreviousError (t);
-                       Error_TypeArgumentsCannotBeUsed (loc, "type", TypeManager.CSharpName (t));
+                       if (expr is TypeExpr) {
+                               Report.SymbolRelatedToPreviousError (expr.Type);
+                               Error_TypeArgumentsCannotBeUsed (loc, "type", expr.GetSignatureForError ());
+                       } else {
+                               expr.Error_ExpressionCannotBeGeneric (loc);
+                       }
                }
 
                public static void Error_TypeArgumentsCannotBeUsed (MethodBase mi, Location loc)
index 785e021eec94d5921539987c43612dc4f613ec7b..d8a1d4b82f21f97fa16c648d26715fb0d29c9f66 100644 (file)
@@ -44,7 +44,7 @@ namespace Mono.CSharp.Nullable
                                        "System", "Nullable`1", Kind.Struct, true);
                        }
 
-                       ConstructedType ctype = new ConstructedType (TypeManager.generic_nullable_type, args, loc);
+                       GenericTypeExpr ctype = new GenericTypeExpr (TypeManager.generic_nullable_type, args, loc);
                        return ctype.ResolveAsTypeTerminal (ec, false);
                }