2010-06-24 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Thu, 24 Jun 2010 14:08:19 +0000 (14:08 -0000)
committerMarek Safar <marek.safar@gmail.com>
Thu, 24 Jun 2010 14:08:19 +0000 (14:08 -0000)
A fix for bug #616809
* generic.cs, expression.cs, ecore.cs: Added a new type expression
for open generic type to pass unbound type arguments to typeof
expression.

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

mcs/mcs/ChangeLog
mcs/mcs/ecore.cs
mcs/mcs/expression.cs
mcs/mcs/generic.cs

index ed76859b238c910e5a62f5615912c0c01966f97b..8e62931927d3cf44fa3d745be9ee66bfa37b925c 100644 (file)
@@ -1,3 +1,10 @@
+2010-06-24  Marek Safar  <marek.safar@gmail.com>
+
+       A fix for bug #616809
+       * generic.cs, expression.cs, ecore.cs: Added a new type expression
+       for open generic type to pass unbound type arguments to typeof
+       expression.
+
 2010-06-24  Marek Safar  <marek.safar@gmail.com>
 
        * statement.cs: Foreach collection implementation refactoring to
index f8656130e6f2b4b98c7fc3f32f2b63103cd8e34c..0e145a3a723727ea90f06e64c5963522890b261a 100644 (file)
@@ -2356,9 +2356,13 @@ namespace Mono.CSharp {
                        FullNamedExpression fne = ec.LookupNamespaceOrType (Name, Arity, loc, /*ignore_cs0104=*/ false);
 
                        if (fne != null) {
-                               if (HasTypeArguments && fne.Type != null && TypeManager.IsGenericType (fne.Type)) {
-                                       GenericTypeExpr ct = new GenericTypeExpr (fne.Type, targs, loc);
-                                       return ct.ResolveAsTypeStep (ec, false);
+                               if (fne.Type != null && Arity > 0) {
+                                       if (HasTypeArguments) {
+                                               GenericTypeExpr ct = new GenericTypeExpr (fne.Type, targs, loc);
+                                               return ct.ResolveAsTypeStep (ec, false);
+                                       }
+
+                                       return new GenericOpenTypeExpr (fne.Type, loc);
                                }
 
                                //
@@ -2368,7 +2372,7 @@ namespace Mono.CSharp {
                                        return fne;
                        }
 
-                       if (!HasTypeArguments && Name == "dynamic" && RootContext.Version > LanguageVersion.V_3) {
+                       if (Arity == 0 && Name == "dynamic" && RootContext.Version > LanguageVersion.V_3) {
                                if (!PredefinedAttributes.Get.Dynamic.IsDefined) {
                                        ec.Compiler.Report.Error (1980, Location,
                                                "Dynamic keyword requires `{0}' to be defined. Are you missing System.Core.dll assembly reference?",
index 3877c4b202ae677ae5e975d3f3554fb33b559a90..3b95ebcb5bddb6f3abbb05e754bd214d2b77b1d0 100644 (file)
@@ -6764,13 +6764,6 @@ namespace Mono.CSharp {
 
                        typearg = texpr.Type;
 
-                       //
-                       // Get generic type definition for unbounded type arguments
-                       //
-                       var tne = QueriedType as ATypeNameExpression;
-                       if (tne != null && typearg.IsGeneric && !tne.HasTypeArguments)
-                               typearg = typearg.GetDefinition ();
-
                        if (typearg == TypeManager.void_type && !(QueriedType is TypeExpression)) {
                                ec.Report.Error (673, loc, "System.Void cannot be used from C#. Use typeof (void) to get the void type object");
                        } else if (typearg.IsPointer && !ec.IsUnsafe){
index 797a285cc441e54111d02fa0b8072d2f0f7519ea..9952f6665b8fcba04e28b9f5a2aa19b0dd6f18e6 100644 (file)
@@ -1812,6 +1812,23 @@ namespace Mono.CSharp {
                }
        }
 
+       //
+       // Generic type with unbound type arguments, used for typeof (G<,,>)
+       //
+       class GenericOpenTypeExpr : TypeExpr
+       {
+               public GenericOpenTypeExpr (TypeSpec type, /*UnboundTypeArguments args,*/ Location loc)
+               {
+                       this.type = type.GetDefinition ();
+                       this.loc = loc;
+               }
+
+               protected override TypeExpr DoResolveAsTypeStep (IMemberContext ec)
+               {
+                       return this;
+               }
+       }
+
        static class ConstraintChecker
        {
                /// <summary>