Revert until fixed
[mono.git] / mcs / mcs / decl.cs
index 7341c4925cb3ebd079ab0cd4a7fe92fbdde00e6a..86a186a16ccfe20d23b8e94bc84b758962edd3e8 100644 (file)
@@ -294,21 +294,6 @@ namespace Mono.CSharp {
                        cached_name = null;
                }
 
-               /// <summary>
-               /// Tests presence of ObsoleteAttribute and report proper error
-               /// </summary>
-               protected void CheckUsageOfObsoleteAttribute (Type type)
-               {
-                       if (type == null)
-                               return;
-
-                       ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (type);
-                       if (obsolete_attr == null)
-                               return;
-
-                       AttributeTester.Report_ObsoleteMessage (obsolete_attr, type.FullName, Location);
-               }
-
                public abstract bool Define ();
 
                // 
@@ -327,16 +312,19 @@ namespace Mono.CSharp {
                /// </summary>
                public virtual void Emit ()
                {
-                       // Hack with Parent == null is for EnumMember
-                       if (Parent == null || (GetObsoleteAttribute (Parent) == null && Parent.GetObsoleteAttribute (Parent) == null))
-                               VerifyObsoleteAttribute ();
-
                        if (!RootContext.VerifyClsCompliance)
                                return;
 
                        VerifyClsCompliance (Parent);
                }
 
+               public virtual EmitContext EmitContext
+               {
+                       get {
+                               return Parent.EmitContext;
+                       }
+               }
+
                public bool InUnsafe {
                        get {
                                return ((ModFlags & Modifiers.UNSAFE) != 0) || Parent.UnsafeContext;
@@ -375,7 +363,7 @@ namespace Mono.CSharp {
                /// <summary>
                /// Returns instance of ObsoleteAttribute for this MemberCore
                /// </summary>
-               public ObsoleteAttribute GetObsoleteAttribute (DeclSpace ds)
+               public virtual ObsoleteAttribute GetObsoleteAttribute ()
                {
                        // ((flags & (Flags.Obsolete_Undetected | Flags.Obsolete)) == 0) is slower, but why ?
                        if ((caching_flags & Flags.Obsolete_Undetected) == 0 && (caching_flags & Flags.Obsolete) == 0) {
@@ -388,11 +376,11 @@ namespace Mono.CSharp {
                                return null;
 
                        Attribute obsolete_attr = OptAttributes.Search (
-                               TypeManager.obsolete_attribute_type, ds.EmitContext);
+                               TypeManager.obsolete_attribute_type, EmitContext);
                        if (obsolete_attr == null)
                                return null;
 
-                       ObsoleteAttribute obsolete = obsolete_attr.GetObsoleteAttribute (ds.EmitContext);
+                       ObsoleteAttribute obsolete = obsolete_attr.GetObsoleteAttribute (EmitContext);
                        if (obsolete == null)
                                return null;
 
@@ -403,9 +391,12 @@ namespace Mono.CSharp {
                /// <summary>
                /// Checks for ObsoleteAttribute presence. It's used for testing of all non-types elements
                /// </summary>
-               public void CheckObsoleteness (Location loc)
+               public virtual void CheckObsoleteness (Location loc)
                {
-                       ObsoleteAttribute oa = GetObsoleteAttribute (Parent);
+                       if (Parent != null)
+                               Parent.CheckObsoleteness (loc);
+
+                       ObsoleteAttribute oa = GetObsoleteAttribute ();
                        if (oa == null) {
                                return;
                        }
@@ -413,10 +404,22 @@ namespace Mono.CSharp {
                        AttributeTester.Report_ObsoleteMessage (oa, GetSignatureForError (), loc);
                }
 
+               protected void CheckObsoleteType (Expression type)
+               {
+                       ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (type.Type);
+                       if (obsolete_attr == null)
+                               return;
+
+                       if (GetObsoleteAttribute () != null || Parent.GetObsoleteAttribute () != null)
+                               return;
+
+                       AttributeTester.Report_ObsoleteMessage (obsolete_attr, TypeManager.CSharpName (type.Type), type.Location);
+               }
+
                /// <summary>
                /// Analyze whether CLS-Compliant verification must be execute for this MemberCore.
                /// </summary>
-               public override bool IsClsCompliaceRequired (DeclSpace container)
+               public override bool IsClsComplianceRequired (DeclSpace container)
                {
                        if ((caching_flags & Flags.ClsCompliance_Undetected) == 0)
                                return (caching_flags & Flags.ClsCompliant) != 0;
@@ -489,12 +492,12 @@ namespace Mono.CSharp {
                /// </summary>
                protected virtual bool VerifyClsCompliance (DeclSpace ds)
                {
-                       if (!IsClsCompliaceRequired (ds)) {
+                       if (!IsClsComplianceRequired (ds)) {
                                if (HasClsCompliantAttribute && RootContext.WarningLevel >= 2) {
                                        if (!IsExposedFromAssembly (ds))
-                                               Report.Warning (3019, Location, "CLS compliance checking will not be performed on `{0}' because it is not visible from outside this assembly", GetSignatureForError ());
+                                               Report.Warning (3019, 2, Location, "CLS compliance checking will not be performed on `{0}' because it is not visible from outside this assembly", GetSignatureForError ());
                                        if (!CodeGen.Assembly.IsClsCompliant)
-                                               Report.Warning (3021, Location, "`{0}' does not need a CLSCompliant attribute because the assembly is not marked as CLS-compliant", GetSignatureForError ());
+                                               Report.Warning (3021, 2, Location, "`{0}' does not need a CLSCompliant attribute because the assembly is not marked as CLS-compliant", GetSignatureForError ());
                                }
                                return false;
                        }
@@ -514,8 +517,6 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               protected abstract void VerifyObsoleteAttribute ();
-
                //
                // Raised (and passed an XmlElement that contains the comment)
                // when GenerateDocComment is writing documentation expectedly.
@@ -576,8 +577,10 @@ namespace Mono.CSharp {
                // The emit context for toplevel objects.
                protected EmitContext ec;
                
-               public EmitContext EmitContext {
-                       get { return ec; }
+               public override EmitContext EmitContext {
+                       get {
+                               return ec;
+                       }
                }
 
                static string[] attribute_targets = new string [] { "type" };
@@ -736,8 +739,6 @@ namespace Mono.CSharp {
                public TypeExpr ResolveBaseTypeExpr (Expression e, bool silent, Location loc)
                {
                        TypeResolveEmitContext.loc = loc;
-                       TypeResolveEmitContext.ContainerType = TypeBuilder;
-
                        return e.ResolveAsTypeTerminal (TypeResolveEmitContext, silent);
                }
                
@@ -1817,7 +1818,7 @@ namespace Mono.CSharp {
                                        }
                                } else {
                                        mi = (MethodInfo) entry.Member;
-                                       cmpAttrs = TypeManager.GetArgumentTypes (mi);
+                                       cmpAttrs = TypeManager.GetParameterData (mi).Types;
                                }
 
                                if (fi != null) {
@@ -2029,7 +2030,7 @@ namespace Mono.CSharp {
                
                                MethodBase method_to_compare = (MethodBase)entry.Member;
                                AttributeTester.Result result = AttributeTester.AreOverloadedMethodParamsClsCompliant (
-                                       method.ParameterTypes, TypeManager.GetArgumentTypes (method_to_compare));
+                                       method.ParameterTypes, TypeManager.GetParameterData (method_to_compare).Types);
 
                                if (result == AttributeTester.Result.Ok)
                                        continue;
@@ -2038,7 +2039,7 @@ namespace Mono.CSharp {
 
                                // TODO: now we are ignoring CLSCompliance(false) on method from other assembly which is buggy.
                                // However it is exactly what csc does.
-                               if (md != null && !md.IsClsCompliaceRequired (method.Parent))
+                               if (md != null && !md.IsClsComplianceRequired (method.Parent))
                                        continue;
                
                                Report.SymbolRelatedToPreviousError (entry.Member);