+2004-08-24 Martin Baulig <martin@ximian.com>
+
+ * typemanager.cs
+ (TypeManager.IsSubclassOf): Renamed to IsFamilyAccessible; use
+ this for accessibility checks.
+ (TypeManager.IsSubclassOrNestedChildOf): Renamed to
+ IsNestedFamilyAccessible.
+ (TypeManager.IsSubclassOf): New method, do what the name actually
+ says.
+
2004-08-24 Martin Baulig <martin@ximian.com>
* expression.cs (MemberAccess.DoResolve): When resolving ourselves
return e;
if (!me.IsStatic &&
- TypeManager.IsSubclassOrNestedChildOf (me.InstanceExpression.Type, me.DeclaringType) &&
+ TypeManager.IsNestedFamilyAccessible (me.InstanceExpression.Type, me.DeclaringType) &&
me.InstanceExpression.Type != me.DeclaringType &&
- !TypeManager.IsSubclassOf (me.InstanceExpression.Type, me.DeclaringType) &&
+ !TypeManager.IsFamilyAccessible (me.InstanceExpression.Type, me.DeclaringType) &&
(!intermediate || !MemberAccess.IdenticalNameAndTypeName (ec, this, e, loc))) {
Error (38, "Cannot access nonstatic member `" + me.Name + "' of " +
"outer type `" + me.DeclaringType + "' via nested type `" +
Type declaring_type = mi.DeclaringType;
if (invocation_type != declaring_type){
- if (TypeManager.IsSubclassOrNestedChildOf (invocation_type, mi.DeclaringType))
+ if (TypeManager.IsNestedFamilyAccessible (invocation_type, mi.DeclaringType))
return mi;
else
return null;
// Family and FamANDAssem require that we derive.
if ((ma == MethodAttributes.Family) || (ma == MethodAttributes.FamANDAssem) || (ma == MethodAttributes.FamORAssem)){
- if (!TypeManager.IsSubclassOrNestedChildOf (invocation_type, mi.DeclaringType))
+ if (!TypeManager.IsNestedFamilyAccessible (invocation_type, mi.DeclaringType))
return null;
else {
if (!TypeManager.IsNestedChildOf (invocation_type, mi.DeclaringType))
}
public static bool IsSubclassOf (Type type, Type parent)
+ {
+ do {
+ if (type.Equals (parent))
+ return true;
+
+ type = type.BaseType;
+ } while (type != null);
+
+ return false;
+ }
+
+ public static bool IsFamilyAccessible (Type type, Type parent)
{
do {
if (IsEqualGenericInstance (type, parent))
//
// Checks whether `type' is a subclass or nested child of `parent'.
//
- public static bool IsSubclassOrNestedChildOf (Type type, Type parent)
+ public static bool IsNestedFamilyAccessible (Type type, Type parent)
{
do {
- if (IsSubclassOf (type, parent))
+ if (IsFamilyAccessible (type, parent))
return true;
// Handle nested types.
if (invocation_type == null)
return false;
- if (!IsSubclassOrNestedChildOf (invocation_type, mb.DeclaringType))
+ if (!IsNestedFamilyAccessible (invocation_type, mb.DeclaringType))
return false;
// Although a derived class can access protected members of its base class
// it cannot do so through an instance of the base class (CS1540).
if (!mb.IsStatic && (qualifier_type != null) &&
!IsEqualGenericInstance (invocation_type, qualifier_type) &&
- TypeManager.IsSubclassOf (invocation_type, qualifier_type) &&
+ TypeManager.IsFamilyAccessible (invocation_type, qualifier_type) &&
!TypeManager.IsNestedChildOf (invocation_type, qualifier_type))
return false;
if (invocation_type == null)
return false;
- if (!IsSubclassOrNestedChildOf (invocation_type, fi.DeclaringType))
+ if (!IsNestedFamilyAccessible (invocation_type, fi.DeclaringType))
return false;
// Although a derived class can access protected members of its base class
// it cannot do so through an instance of the base class (CS1540).
if (!fi.IsStatic && (qualifier_type != null) &&
!IsEqualGenericInstance (invocation_type, qualifier_type) &&
- TypeManager.IsSubclassOf (invocation_type, qualifier_type) &&
+ TypeManager.IsFamilyAccessible (invocation_type, qualifier_type) &&
!TypeManager.IsNestedChildOf (invocation_type, qualifier_type))
return false;