2004-03-16 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Tue, 16 Mar 2004 19:19:51 +0000 (19:19 -0000)
committerMartin Baulig <martin@novell.com>
Tue, 16 Mar 2004 19:19:51 +0000 (19:19 -0000)
* class.cs (TypeContainer.GetClassBases): Moved
Error_TypeParameterAsBase() here and also check whether the base
class is not an attribute.

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

mcs/gmcs/ChangeLog
mcs/gmcs/class.cs
mcs/gmcs/generic.cs

index 7eba1dac1641c2b04831b1a2446cc115b49eb5cc..18689196c6aae7e9d42204c8ff4d0e9367ea6b43 100755 (executable)
@@ -1,3 +1,9 @@
+2004-03-16  Martin Baulig  <martin@ximian.com>
+
+       * class.cs (TypeContainer.GetClassBases): Moved
+       Error_TypeParameterAsBase() here and also check whether the base
+       class is not an attribute.
+
 2004-03-16  Martin Baulig  <martin@ximian.com>
 
        * class.cs (TypeContainer.GetClassBases): Fix the CS0528 check.
index da10c472e2569a71b05d4de7bda71755e844c350..0c8fa33bf7dae442df59d3afb9df5b05e0a3ce4f 100755 (executable)
@@ -618,14 +618,6 @@ namespace Mono.CSharp {
                        }
                }
 
-               void Error_TypeParameterAsBase (TypeParameterExpr e)
-               {
-                       Report.Error (
-                               689, e.Location,
-                               "Type parameter `{0}' can not be used as a " +
-                               "base class or interface", e.Name);
-               }
-
                /// <remarks>
                ///  The pending methods that need to be implemented (interfaces or abstract methods)
                /// </remarks>
@@ -687,7 +679,19 @@ namespace Mono.CSharp {
                                }
 
                                if (name is TypeParameterExpr){
-                                       Error_TypeParameterAsBase ((TypeParameterExpr) name);
+                                       Report.Error (
+                                               689, name.Location,
+                                               "Type parameter `{0}' can not be used as a " +
+                                               "base class or interface", name.Name);
+                                       error = true;
+                                       return null;
+                               }
+
+                               if (IsGeneric && name.IsAttribute){
+                                       Report.Error (
+                                               698, name.Location,
+                                               "A generic type cannot derive from `{0}' " +
+                                               "because it is an attribute class", name.Name);
                                        error = true;
                                        return null;
                                }
@@ -734,10 +738,11 @@ namespace Mono.CSharp {
                                base_class_name = parent.Name;
 
                        TypeExpr [] ifaces = new TypeExpr [count-start];
-                       
+
                        for (i = start, j = 0; i < count; i++, j++){
                                Expression name = (Expression) bases [i];
                                TypeExpr resolved = ResolveTypeExpr (name, false, Location);
+
                                if (resolved == null)
                                        return null;
                                
index f643a3fa0fe4cb79c4554d14b460ecda343a9a16..5e4f98151f64185fb9a62d25c01992d3abfbe2cf 100644 (file)
@@ -530,12 +530,28 @@ namespace Mono.CSharp {
                        get { return gt.IsSealed; }
                }
 
+               public override bool IsAttribute {
+                       get { return false; }
+               }
+
                public override TypeExpr[] GetInterfaces ()
                {
                        TypeExpr[] ifaces = TypeManager.GetInterfaces (gt);
                        return ifaces;
                }
 
+               public override bool Equals (object obj)
+               {
+                       ConstructedType cobj = obj as ConstructedType;
+                       if (cobj == null)
+                               return false;
+
+                       if ((type == null) || (cobj.type == null))
+                               return false;
+
+                       return type == cobj.type;
+               }
+
                public override string Name {
                        get {
                                return full_name;