make line-endings uniform
[mono.git] / mcs / mcs / decl.cs
index 336c6b3c420ed7155ec229bd087cfc6830f5f4a6..6bbec398fe873cbc96eebce9830831691164c74c 100644 (file)
@@ -559,13 +559,19 @@ namespace Mono.CSharp {
                                return false;
                        }
 
-                       if (!CodeGen.Assembly.IsClsCompliant) {
-                               if (HasClsCompliantAttribute) {
+                       if (HasClsCompliantAttribute) {
+                               if (CodeGen.Assembly.ClsCompliantAttribute == null && !CodeGen.Assembly.IsClsCompliant) {
                                        Report.Error (3014, Location,
                                                "`{0}' cannot be marked as CLS-compliant because the assembly is not marked as CLS-compliant",
                                                GetSignatureForError ());
+                                       return false;
+                               }
+
+                               if (!Parent.IsClsComplianceRequired ()) {
+                                       Report.Warning (3018, 1, Location, "`{0}' cannot be marked as CLS-compliant because it is a member of non CLS-compliant type `{1}'", 
+                                               GetSignatureForError (), Parent.GetSignatureForError ());
+                                       return false;
                                }
-                               return false;
                        }
 
                        if (member_name.Name [0] == '_') {
@@ -832,7 +838,7 @@ namespace Mono.CSharp {
                public bool CheckAccessLevel (Type check_type)
                {
                        TypeBuilder tb;
-                       if ((this is GenericMethod) || (this is Iterator))
+                       if (this is GenericMethod)
                                tb = Parent.TypeBuilder;
                        else
                                tb = TypeBuilder;
@@ -847,11 +853,6 @@ namespace Mono.CSharp {
                                //        May also be null when resolving top-level attributes.
                                return true;
 
-                       if (TypeManager.IsGenericParameter (check_type))
-                               return true; // FIXME
-                       
-                       TypeAttributes check_attr = check_type.Attributes & TypeAttributes.VisibilityMask;
-
                        //
                        // Broken Microsoft runtime, return public for arrays, no matter what 
                        // the accessibility is for their underlying class, and they return 
@@ -860,6 +861,11 @@ namespace Mono.CSharp {
                        if (check_type.IsArray || check_type.IsPointer)
                                return CheckAccessLevel (TypeManager.GetElementType (check_type));
 
+                       if (TypeManager.IsGenericParameter(check_type))
+                               return true; // FIXME
+
+                       TypeAttributes check_attr = check_type.Attributes & TypeAttributes.VisibilityMask;
+
                        switch (check_attr){
                        case TypeAttributes.Public:
                                return true;
@@ -996,9 +1002,6 @@ namespace Mono.CSharp {
                //
                public bool AsAccessible (Type p, int flags)
                {
-                       if (TypeManager.IsGenericParameter (p))
-                               return true; // FIXME
-
                        //
                        // 1) if M is private, its accessability is the same as this declspace.
                        // we already know that P is accessible to T before this method, so we
@@ -1010,7 +1013,10 @@ namespace Mono.CSharp {
                        
                        while (p.IsArray || p.IsPointer || p.IsByRef)
                                p = TypeManager.GetElementType (p);
-                       
+
+                       if (TypeManager.IsGenericParameter(p))
+                               return true; // FIXME
+
                        AccessLevel pAccess = TypeEffectiveAccessLevel (p);
                        AccessLevel mAccess = this.EffectiveAccessLevel &
                                GetAccessLevelFromModifiers (flags);
@@ -1152,16 +1158,14 @@ namespace Mono.CSharp {
                                the_parent = null;
 
                        int start = 0;
-                       TypeParameter[] parent_params = null;
-                       if ((the_parent != null) && the_parent.IsGeneric) {
-                               parent_params = the_parent.initialize_type_params ();
-                               start = parent_params != null ? parent_params.Length : 0;
-                       }
-
                        ArrayList list = new ArrayList ();
-                       if (parent_params != null)
+                       if (the_parent != null && the_parent.IsGeneric) {
+                               // FIXME: move generics info out of DeclSpace
+                               TypeParameter[] parent_params = the_parent.PartialContainer.TypeParameters;
+                               start = parent_params.Length;
                                list.AddRange (parent_params);
-
+                       }
                        int count = type_params != null ? type_params.Length : 0;
                        for (int i = 0; i < count; i++) {
                                TypeParameter param = type_params [i];
@@ -1305,6 +1309,9 @@ namespace Mono.CSharp {
                        }
 
                        IDictionary cache = TypeManager.AllClsTopLevelTypes;
+                       if (cache == null)
+                               return true;
+
                        string lcase = Name.ToLower (System.Globalization.CultureInfo.InvariantCulture);
                        if (!cache.Contains (lcase)) {
                                cache.Add (lcase, this);
@@ -2072,6 +2079,33 @@ namespace Mono.CSharp {
                        
                        return null;
                }
+
+               public MemberInfo FindBaseEvent (Type invocationType, string name)
+               {
+                       ArrayList applicable;
+                       if (method_hash != null)
+                               applicable = (ArrayList) method_hash [name];
+                       else
+                               applicable = (ArrayList) member_hash [name];
+                       
+                       if (applicable == null)
+                               return null;
+
+                       //
+                       // Walk the chain of events, starting from the top.
+                       //
+                       for (int i = applicable.Count - 1; i >= 0; i--) 
+                       {
+                               CacheEntry entry = (CacheEntry) applicable [i];
+                               if ((entry.EntryType & EntryType.Event) == 0)
+                                       continue;
+                               
+                               EventInfo ei = (EventInfo)entry.Member;
+                               return ei.GetAddMethod (true);
+                       }
+
+                       return null;
+               }
                
                //
                // This finds the method or property for us to override. invocationType is the type where