2008-11-13 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Thu, 13 Nov 2008 10:04:25 +0000 (10:04 -0000)
committerMarek Safar <marek.safar@gmail.com>
Thu, 13 Nov 2008 10:04:25 +0000 (10:04 -0000)
* generic.cs, expression.cs, ecore.cs, cs-parser.jay: Removed
useless UnboundTypeExpression.

* attribute.cs: Do check obsolete attribute on generic types.

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

mcs/mcs/ChangeLog
mcs/mcs/attribute.cs
mcs/mcs/cs-parser.jay
mcs/mcs/ecore.cs
mcs/mcs/expression.cs
mcs/mcs/generic.cs

index 1ba4f1f0cef81e302bb3f4213a09e512e66e4d1d..b4dcfaaeadba0d115ae1c7369d464f96513708aa 100644 (file)
@@ -1,3 +1,10 @@
+2008-11-13  Marek Safar  <marek.safar@gmail.com>
+
+       * generic.cs, expression.cs, ecore.cs, cs-parser.jay: Removed
+       useless UnboundTypeExpression.
+       
+       * attribute.cs: Do check obsolete attribute on generic types.
+
 2008-11-12  Marek Safar  <marek.safar@gmail.com>
 
        A fix for bugs #425680, #400139
index f95ca55df2f1461b6ef21f65bcdbfb09b9904c2a..291cb53466324cf5a51bfa25d7f536cbec5c2031 100644 (file)
@@ -1723,17 +1723,19 @@ namespace Mono.CSharp {
                        ObsoleteAttribute result = null;
                        if (TypeManager.HasElementType (type)) {
                                result = GetObsoleteAttribute (TypeManager.GetElementType (type));
-                       } else if (TypeManager.IsGenericParameter (type) || TypeManager.IsGenericType (type))
-                               return null;
-                       else {
+                       } else if (TypeManager.IsGenericParameter (type))
+                               result = null;  // TODO: throw new NotSupportedException ()
+                       else if (TypeManager.IsGenericType (type) && !TypeManager.IsGenericTypeDefinition (type)) {
+                               return GetObsoleteAttribute (TypeManager.DropGenericTypeArguments (type));
+                       } else {
                                DeclSpace type_ds = TypeManager.LookupDeclSpace (type);
 
                                // Type is external, we can get attribute directly
                                if (type_ds == null) {
                                        if (TypeManager.obsolete_attribute_type != null) {
-                                               object [] attribute = type.GetCustomAttributes (TypeManager.obsolete_attribute_type, false);
+                                               object[] attribute = type.GetCustomAttributes (TypeManager.obsolete_attribute_type, false);
                                                if (attribute.Length == 1)
-                                                       result = (ObsoleteAttribute) attribute [0];
+                                                       result = (ObsoleteAttribute) attribute[0];
                                        }
                                } else {
                                        result = type_ds.GetObsoleteAttribute ();
index 0edf483091aafc5742b6e4308a31188e8ddd9122..c9bc548c9918d9ce5fc9a098fa08afc5f7c2969c 100644 (file)
@@ -3495,13 +3495,7 @@ typeof_expression
        
 typeof_type_expression
        : type_and_void
-         {
-               $$ = $1;
-         }
        | unbound_type_name
-         {
-               $$ = new UnboundTypeExpression ((MemberName)$1, lexer.Location);
-         }
        | error
         {
                Error_TypeExpected (lexer.Location);
@@ -3515,29 +3509,27 @@ unbound_type_name
                LocatedToken lt = (LocatedToken) $1;
                TypeArguments ta = (TypeArguments)$2;
 
-               $$ = new MemberName (lt.Value, ta, lt.Location);
+               $$ = new SimpleName (MemberName.MakeName (lt.Value, ta), lt.Location);
          }
        | qualified_alias_member IDENTIFIER generic_dimension
          {
                LocatedToken lt1 = (LocatedToken) $1;
                LocatedToken lt2 = (LocatedToken) $2;
-               TypeArguments ta = (TypeArguments)$3;
 
-               $$ = new MemberName (new MemberName (lt1.Value, lt1.Location), lt2.Value, ta, lt2.Location);
+               $$ = new QualifiedAliasMember (lt1.Value, MemberName.MakeName (lt2.Value, (TypeArguments) $3), lt1.Location);
          }
        | unbound_type_name DOT IDENTIFIER generic_dimension
          {
                LocatedToken lt = (LocatedToken) $3;
-               TypeArguments ta = (TypeArguments)$4;
                
-               $$ = new MemberName ((MemberName)$1, lt.Value, ta, lt.Location);
+               $$ = new MemberAccess ((Expression) $1, MemberName.MakeName (lt.Value, (TypeArguments) $4), lt.Location);               
          }
        | namespace_or_type_name DOT IDENTIFIER generic_dimension
          {
                LocatedToken lt = (LocatedToken) $3;
-               TypeArguments ta = (TypeArguments)$4;
-               
-               $$ = new MemberName ((MemberName)$1, lt.Value, ta, lt.Location);                
+               MemberName name = (MemberName) $1;
+
+               $$ = new MemberAccess (name.GetTypeExpression (), MemberName.MakeName (lt.Value, (TypeArguments) $4), lt.Location);             
          }
        ;
        
index f6b251c0bfd38c1a84e39065a1fc4020ee3c364b..e96638f6a87ff803d1aed503528285a744af302d 100644 (file)
@@ -2782,18 +2782,19 @@ namespace Mono.CSharp {
 
                        return e;
                }
-               
-               protected override void CloneTo (CloneContext clonectx, Expression target)
-               {
-                       // CloneTo: Nothing, we do not keep any state on this expression
-               }
        }
 
        /// <summary>
        ///   Represents a namespace or a type.  The name of the class was inspired by
        ///   section 10.8.1 (Fully Qualified Names).
        /// </summary>
-       public abstract class FullNamedExpression : Expression {
+       public abstract class FullNamedExpression : Expression
+       {
+               protected override void CloneTo (CloneContext clonectx, Expression target)
+               {
+                       // Do nothing, most unresolved type expressions cannot be
+                       // resolved to different type
+               }
 
                public override Expression CreateExpressionTree (EmitContext ec)
                {
@@ -3049,11 +3050,6 @@ namespace Mono.CSharp {
                        return this;
                }
 
-               protected override void CloneTo (CloneContext clonectx, Expression target)
-               {
-                       // CloneTo: Nothing, we do not keep any state on this expression
-               }
-
                public override string GetSignatureForError ()
                {
                        if (type == null)
@@ -3063,44 +3059,6 @@ namespace Mono.CSharp {
                }
        }
 
-       /// <summary>
-       ///   Represents an "unbound generic type", ie. typeof (Foo<>).
-       ///   See 14.5.11.
-       /// </summary>
-       public class UnboundTypeExpression : TypeExpr
-       {
-               MemberName name;
-
-               public UnboundTypeExpression (MemberName name, Location l)
-               {
-                       this.name = name;
-                       loc = l;
-               }
-
-               protected override void CloneTo (CloneContext clonectx, Expression target)
-               {
-                       // Nothing to clone
-               }
-
-               protected override TypeExpr DoResolveAsTypeStep (IResolveContext ec)
-               {
-                       Expression expr;
-                       if (name.Left != null) {
-                               Expression lexpr = name.Left.GetTypeExpression ();
-                               expr = new MemberAccess (lexpr, name.Basename);
-                       } else {
-                               expr = new SimpleName (name.Basename, loc);
-                       }
-
-                       FullNamedExpression fne = expr.ResolveAsTypeStep (ec, false);
-                       if (fne == null)
-                               return null;
-
-                       type = fne.Type;
-                       return new TypeExpression (type, loc);
-               }
-       }
-
        /// <summary>
        ///   This class denotes an expression which evaluates to a member
        ///   of a struct or a class.
index c01a7dc3ed2a9eb1edf10de9688b575e9e715a82..2baec49d196916728c4d78a9c083eee94c5b162f 100644 (file)
@@ -8981,13 +8981,6 @@ namespace Mono.CSharp {
                        return left.GetSignatureForError () + dim;
                }
 
-               protected override void CloneTo (CloneContext clonectx, Expression t)
-               {
-                       ComposedCast target = (ComposedCast) t;
-
-                       target.left = (FullNamedExpression)left.Clone (clonectx);
-               }
-               
                public override TypeExpr ResolveAsTypeTerminal (IResolveContext ec, bool silent)
                {
                        return ResolveAsBaseTerminal (ec, silent);
index e428f942ce9053b2d2212589f39f821d434bb5ce..52ea9becac91f2a267948272956d555c059b1574 100644 (file)
@@ -1362,11 +1362,6 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               public Expression GetSimpleName (EmitContext ec)
-               {
-                       return this;
-               }
-
                public override bool CheckAccessLevel (DeclSpace ds)
                {
                        return ds.CheckAccessLevel (gt);