[mcs] When setting struct empty layout consider compiler generated fields. Fixes...
[mono.git] / mcs / mcs / decl.cs
index 56d423ad23d6ccb754014c5a28a574cb027f69f1..0f0b1d1bb69749696d80b025d5da5bf27faf276b 100644 (file)
@@ -18,7 +18,7 @@ using System.Diagnostics;
 using System.Text;
 using Mono.CompilerServices.SymbolWriter;
 
-#if NET_2_1
+#if MOBILE
 using XmlElement = System.Object;
 #else
 using System.Xml;
@@ -195,11 +195,6 @@ namespace Mono.CSharp {
 
                        return name + "`" + args.Count;
                }
-
-               public static string MakeName (string name, int count)
-               {
-                       return name + "`" + count;
-               }
        }
 
        public class SimpleMemberName
@@ -295,7 +290,8 @@ namespace Mono.CSharp {
                        HasInstanceConstructor = 1 << 16,
                        HasUserOperators = 1 << 17,
                        CanBeReused = 1 << 18,
-                       InterfacesExpanded = 1 << 19
+                       InterfacesExpanded = 1 << 19,
+                       HasInstanceField = 1 << 20
                }
 
                /// <summary>
@@ -513,16 +509,6 @@ namespace Mono.CSharp {
                        return obsolete;
                }
 
-               /// <summary>
-               /// Checks for ObsoleteAttribute presence. It's used for testing of all non-types elements
-               /// </summary>
-               public virtual void CheckObsoleteness (Location loc)
-               {
-                       ObsoleteAttribute oa = GetAttributeObsolete ();
-                       if (oa != null)
-                               AttributeTester.Report_ObsoleteMessage (oa, GetSignatureForError (), loc, Report);
-               }
-
                //
                // Checks whether the type P is as accessible as this member
                //
@@ -539,6 +525,9 @@ namespace Mono.CSharp {
                        while (TypeManager.HasElementType (p))
                                p = TypeManager.GetElementType (p);
 
+                       if (p.BuiltinType != BuiltinTypeSpec.Type.None)
+                               return true;
+
                        if (p.IsGenericParameter)
                                return true;
 
@@ -558,6 +547,10 @@ namespace Mono.CSharp {
 
                                bool same_access_restrictions = false;
                                for (MemberCore mc = this; !same_access_restrictions && mc != null && mc.Parent != null; mc = mc.Parent) {
+                                       var tc = mc as TypeContainer;
+                                       if (tc != null && tc.PartialContainer != null)
+                                               mc = tc.PartialContainer;
+
                                        var al = mc.ModFlags & Modifiers.AccessibilityMask;
                                        switch (pAccess) {
                                        case Modifiers.INTERNAL:
@@ -578,8 +571,11 @@ namespace Mono.CSharp {
                                                        // protected type then the type is accessible
                                                        //
                                                        while (mc.Parent != null && mc.Parent.PartialContainer != null) {
-                                                               if (mc.Parent.PartialContainer.IsBaseTypeDefinition (p_parent))
+                                                               if (mc.Parent.PartialContainer.IsBaseTypeDefinition (p_parent)) {
                                                                        same_access_restrictions = true;
+                                                                       break;
+                                                               }
+
                                                                mc = mc.Parent; 
                                                        }
                                                }
@@ -591,8 +587,15 @@ namespace Mono.CSharp {
                                                        same_access_restrictions = p.MemberDefinition.IsInternalAsPublic (mc.Module.DeclaringAssembly);
                                                else if (al == (Modifiers.PROTECTED | Modifiers.INTERNAL))
                                                        same_access_restrictions = mc.Parent.PartialContainer.IsBaseTypeDefinition (p_parent) && p.MemberDefinition.IsInternalAsPublic (mc.Module.DeclaringAssembly);
-                                               else
+                                               else if (al == Modifiers.PROTECTED)
                                                        goto case Modifiers.PROTECTED;
+                                               else if (al == Modifiers.PRIVATE) {
+                                                       if (p.MemberDefinition.IsInternalAsPublic (mc.Module.DeclaringAssembly)) {
+                                                               same_access_restrictions = true;
+                                                       } else {
+                                                               goto case Modifiers.PROTECTED;
+                                                       }
+                                               }
 
                                                break;
 
@@ -675,13 +678,13 @@ namespace Mono.CSharp {
                // Does extension methods look up to find a method which matches name and extensionType.
                // Search starts from this namespace and continues hierarchically up to top level.
                //
-               public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
+               public ExtensionMethodCandidates LookupExtensionMethod (string name, int arity)
                {
                        var m = Parent;
                        do {
                                var ns = m as NamespaceContainer;
                                if (ns != null)
-                                       return ns.LookupExtensionMethod (this, extensionType, name, arity, 0);
+                                       return ns.LookupExtensionMethod (this, name, arity, 0);
 
                                m = m.Parent;
                        } while (m != null);
@@ -1066,6 +1069,16 @@ namespace Mono.CSharp {
 
                #endregion
 
+               public virtual void CheckObsoleteness (IMemberContext mc, Location loc)
+               {
+                       var oa = GetAttributeObsolete ();
+                       if (oa == null)
+                               return;
+
+                       if (!mc.IsObsolete)
+                               AttributeTester.Report_ObsoleteMessage (oa, GetSignatureForError (), loc, mc.Module.Compiler.Report);
+               }
+
                public virtual ObsoleteAttribute GetAttributeObsolete ()
                {
                        if ((state & (StateFlags.Obsolete | StateFlags.Obsolete_Undetected)) == 0)
@@ -1130,7 +1143,7 @@ namespace Mono.CSharp {
 
                public virtual string GetSignatureForError ()
                {
-                       var bf = MemberDefinition as Property.BackingField;
+                       var bf = MemberDefinition as Property.BackingFieldDeclaration;
                        string name;
                        if (bf == null) {
                                name = Name;