* codegen.cs (IResolveContent.GenericDeclContainer): Copy from gmcs.
[mono.git] / mcs / gmcs / decl.cs
index 445be34330d9b45a587d26d7e3023e2bba252672..7ec2b071653b160d5d7f980d829d26c8e76866f5 100644 (file)
@@ -29,53 +29,58 @@ namespace Mono.CSharp {
                public readonly MemberName Left;
                public readonly Location Location;
 
-               public static readonly MemberName Null = new MemberName ("", Location.Null);
+               public static readonly MemberName Null = new MemberName ("");
 
                bool is_double_colon;
 
                private MemberName (MemberName left, string name, bool is_double_colon,
-                                   TypeArguments args, Location loc)
+                                   Location loc)
                {
                        this.Name = name;
                        this.Location = loc;
                        this.is_double_colon = is_double_colon;
-                       this.TypeArguments = args;
                        this.Left = left;
                }
 
-               public MemberName (string name, TypeArguments args, Location loc)
-                       : this (name, loc)
+               private MemberName (MemberName left, string name, bool is_double_colon,
+                                   TypeArguments args, Location loc)
+                       : this (left, name, is_double_colon, loc)
                {
                        this.TypeArguments = args;
                }
 
+               public MemberName (string name)
+                       : this (name, Location.Null)
+               { }
+
                public MemberName (string name, Location loc)
-               {
-                       this.Name = name;
-                       this.Location = loc;
-               }
+                       : this (null, name, false, loc)
+               { }
+
+               public MemberName (string name, TypeArguments args, Location loc)
+                       : this (null, name, false, args, loc)
+               { }
+
+               public MemberName (MemberName left, string name)
+                       : this (left, name, left != null ? left.Location : Location.Null)
+               { }
 
                public MemberName (MemberName left, string name, Location loc)
-                       : this (name, loc)
-               {
-                       this.Left = left;
-               }
+                       : this (left, name, false, loc)
+               { }
 
                public MemberName (MemberName left, string name, TypeArguments args, Location loc)
-                       : this (name, args, loc)
-               {
-                       this.Left = left;
-               }
+                       : this (left, name, false, args, loc)
+               { }
+
 
                public MemberName (string alias, string name, Location loc)
-                       : this (new MemberName (alias, loc), name, true, null, loc)
-               {
-               }
+                       : this (new MemberName (alias, loc), name, true, loc)
+               { }
 
                public MemberName (MemberName left, MemberName right)
                        : this (left, right, right.Location)
-               {
-               }
+               { }
 
                public MemberName (MemberName left, MemberName right, Location loc)
                        : this (null, right.Name, false, right.TypeArguments, loc)
@@ -85,26 +90,9 @@ namespace Mono.CSharp {
                        this.Left = (right.Left == null) ? left : new MemberName (left, right.Left);
                }
 
-               static readonly char [] dot_array = { '.' };
-
-               public static MemberName FromDotted (string name, Location loc)
-               {
-                       string [] elements = name.Split (dot_array);
-                       int count = elements.Length;
-                       int i = 0;
-                       MemberName n = new MemberName (elements [i++], loc);
-                       while (i < count)
-                               n = new MemberName (n, elements [i++], loc);
-                       return n;
-               }
-
                public string GetName ()
                {
-                       string connect = is_double_colon ? "::" : ".";
-                       if (Left != null)
-                               return Left.GetName () + connect + Name;
-                       else
-                               return Name;
+                       return GetName (false);
                }
 
                public bool IsGeneric {
@@ -128,71 +116,15 @@ namespace Mono.CSharp {
                                return name;
                }
 
-               public int CountTypeArguments {
-                       get {
-                               if (TypeArguments == null)
-                                       return 0;
-                               else
-                                       return TypeArguments.Count;
-                       }
-               }
-
-               public string MethodName {
-                       get {
-                               string connect = is_double_colon ? "::" : ".";
-                               if (Left != null)
-                                       return Left.FullName + connect + Name;
-                               else
-                                       return Name;
-                       }
-               }
-
-               public static string MakeName (string name, TypeArguments args)
-               {
-                       if (args == null)
-                               return name;
-                       else
-                               return name + "`" + args.Count;
-               }
-
-               public static string MakeName (string name, int count)
-               {
-                       return name + "`" + count;
-               }
-
                public string GetTypeName ()
                {
                        string connect = is_double_colon ? "::" : ".";
                        if (Left != null)
-                               return Left.GetTypeName () + connect +
-                                       MakeName (Name, TypeArguments);
+                               return Left.GetTypeName () + connect + MakeName (Name, TypeArguments);
                        else
                                return MakeName (Name, TypeArguments);
                }
 
-               protected bool IsUnbound {
-                       get {
-                               if ((Left != null) && Left.IsUnbound)
-                                       return true;
-                               else if (TypeArguments == null)
-                                       return false;
-                               else
-                                       return TypeArguments.IsUnbound;
-                       }
-               }
-
-               protected bool CheckUnbound (Location loc)
-               {
-                       if ((Left != null) && !Left.CheckUnbound (loc))
-                               return false;
-                       if ((TypeArguments != null) && !TypeArguments.IsUnbound) {
-                               Report.Error (1031, loc, "Type expected");
-                               return false;
-                       }
-
-                       return true;
-               }
-
                public Expression GetTypeExpression ()
                {
                        if (IsUnbound) {
@@ -216,7 +148,7 @@ namespace Mono.CSharp {
                        }
 
                        Expression lexpr = Left.GetTypeExpression ();
-                       return new MemberAccess (lexpr, Name, TypeArguments);
+                       return new MemberAccess (lexpr, Name, TypeArguments, Location);
                }
 
                public MemberName Clone ()
@@ -243,6 +175,16 @@ namespace Mono.CSharp {
                        }
                }
 
+               public string MethodName {
+                       get {
+                               string connect = is_double_colon ? "::" : ".";
+                               if (Left != null)
+                                       return Left.FullName + connect + Name;
+                               else
+                                       return Name;
+                       }
+               }
+
                public override string ToString ()
                {
                        string connect = is_double_colon ? "::" : ".";
@@ -292,6 +234,51 @@ namespace Mono.CSharp {
 
                        return hash & 0x7FFFFFFF;
                }
+
+               public int CountTypeArguments {
+                       get {
+                               if (TypeArguments == null)
+                                       return 0;
+                               else
+                                       return TypeArguments.Count;
+                       }
+               }
+
+               public static string MakeName (string name, TypeArguments args)
+               {
+                       if (args == null)
+                               return name;
+                       else
+                               return name + "`" + args.Count;
+               }
+
+               public static string MakeName (string name, int count)
+               {
+                       return name + "`" + count;
+               }
+
+               protected bool IsUnbound {
+                       get {
+                               if ((Left != null) && Left.IsUnbound)
+                                       return true;
+                               else if (TypeArguments == null)
+                                       return false;
+                               else
+                                       return TypeArguments.IsUnbound;
+                       }
+               }
+
+               protected bool CheckUnbound (Location loc)
+               {
+                       if ((Left != null) && !Left.CheckUnbound (loc))
+                               return false;
+                       if ((TypeArguments != null) && !TypeArguments.IsUnbound) {
+                               Report.Error (1031, loc, "Type expected");
+                               return false;
+                       }
+
+                       return true;
+               }
        }
 
        /// <summary>
@@ -517,7 +504,10 @@ namespace Mono.CSharp {
                                        TypeManager.cls_compliant_attribute_type);
                                if (cls_attribute != null) {
                                        caching_flags |= Flags.HasClsCompliantAttribute;
-                                       return cls_attribute.GetClsCompliantAttributeValue ();
+                                       bool value = cls_attribute.GetClsCompliantAttributeValue ();
+                                       if (value)
+                                               caching_flags |= Flags.ClsCompliantAttributeTrue;
+                                       return value;
                                }
                        }
 
@@ -1134,9 +1124,11 @@ namespace Mono.CSharp {
                                if (param.Name != name)
                                        continue;
 
+                               Report.SymbolRelatedToPreviousError (Parent);
+                               // TODO: Location is wrong (parent instead of child)
                                Report.Warning (693, 3, Location,
-                                       "Type parameter `{0}' has same name as type parameter from outer type `{1}'",
-                                       name, Parent.GetInstantiationName ());
+                                       "Type parameter `{0}' has the same name as the type parameter from outer type `{1}'",
+                                       name, Parent.GetSignatureForError ());
 
                                return false;
                        }