+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
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 ();
typeof_type_expression
: type_and_void
- {
- $$ = $1;
- }
| unbound_type_name
- {
- $$ = new UnboundTypeExpression ((MemberName)$1, lexer.Location);
- }
| error
{
Error_TypeExpected (lexer.Location);
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);
}
;
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)
{
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)
}
}
- /// <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.
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);
return true;
}
- public Expression GetSimpleName (EmitContext ec)
- {
- return this;
- }
-
public override bool CheckAccessLevel (DeclSpace ds)
{
return ds.CheckAccessLevel (gt);