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] == '_') {
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;
// 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
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;
//
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
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);
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];
return false;
}
+ if (type_params != null) {
+ foreach (TypeParameter tp in type_params) {
+ if (tp.Constraints == null)
+ continue;
+
+ tp.Constraints.VerifyClsCompliance ();
+ }
+ }
+
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);
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
// TODO: Almost duplicate !
// Check visibility
switch (fi.Attributes & FieldAttributes.FieldAccessMask) {
- case FieldAttributes.Private:
- //
- // A private method is Ok if we are a nested subtype.
- // The spec actually is not very clear about this, see bug 52458.
- //
- if (invocationType != entry.Container.Type &
- TypeManager.IsNestedChildOf (invocationType, entry.Container.Type))
- continue;
-
- break;
- case FieldAttributes.FamANDAssem:
- case FieldAttributes.Assembly:
- //
- // Check for assembly methods
- //
- if (mi.DeclaringType.Assembly != CodeGen.Assembly.Builder)
- continue;
- break;
+ case FieldAttributes.PrivateScope:
+ continue;
+ case FieldAttributes.Private:
+ //
+ // A private method is Ok if we are a nested subtype.
+ // The spec actually is not very clear about this, see bug 52458.
+ //
+ if (!invocationType.Equals (entry.Container.Type) &&
+ !TypeManager.IsNestedChildOf (invocationType, entry.Container.Type))
+ continue;
+ break;
+ case FieldAttributes.FamANDAssem:
+ case FieldAttributes.Assembly:
+ //
+ // Check for assembly methods
+ //
+ if (mi.DeclaringType.Assembly != CodeGen.Assembly.Builder)
+ continue;
+ break;
}
return entry.Member;
}
if (cmpAttrs.Length != paramTypes.Length)
continue;
- for (int j = cmpAttrs.Length - 1; j >= 0; j --) {
+ int j;
+ for (j = 0; j < cmpAttrs.Length; ++j)
if (!TypeManager.IsEqual (paramTypes [j], cmpAttrs [j]))
- goto next;
- }
+ break;
+ if (j < cmpAttrs.Length)
+ continue;
//
// check generic arguments for methods
//
if (mi != null) {
Type [] cmpGenArgs = TypeManager.GetGenericArguments (mi);
- if ((genericMethod != null) && (cmpGenArgs.Length > 0)) {
- if (genericMethod.TypeParameters.Length != cmpGenArgs.Length)
- goto next;
- } else if (!((genericMethod == null) && (cmpGenArgs.Length == 0)))
- goto next;
+ if (genericMethod == null && cmpGenArgs.Length != 0)
+ continue;
+ if (genericMethod != null && cmpGenArgs.Length != genericMethod.TypeParameters.Length)
+ continue;
}
-
+
//
// get one of the methods because this has the visibility info.
//
// Check visibility
//
switch (mi.Attributes & MethodAttributes.MemberAccessMask) {
+ case MethodAttributes.PrivateScope:
+ continue;
case MethodAttributes.Private:
//
// A private method is Ok if we are a nested subtype.
// The spec actually is not very clear about this, see bug 52458.
//
- if (invocationType.Equals (entry.Container.Type) ||
- TypeManager.IsNestedChildOf (invocationType, entry.Container.Type))
- return entry.Member;
-
+ if (!invocationType.Equals (entry.Container.Type) &&
+ !TypeManager.IsNestedChildOf (invocationType, entry.Container.Type))
+ continue;
break;
case MethodAttributes.FamANDAssem:
case MethodAttributes.Assembly:
//
// Check for assembly methods
//
- if (mi.DeclaringType.Assembly == CodeGen.Assembly.Builder)
- return entry.Member;
-
+ if (mi.DeclaringType.Assembly != CodeGen.Assembly.Builder)
+ continue;
break;
- default:
- //
- // A protected method is ok, because we are overriding.
- // public is always ok.
- //
- return entry.Member;
}
- next:
- ;
+ return entry.Member;
}
return null;