public bool IsAccessible (TypeSpec invocationType)
{
var ma = Modifiers & Modifiers.AccessibilityMask;
if (ma == Modifiers.PUBLIC)
return true;
var parentType = /* this as TypeSpec ?? */ DeclaringType;
// It's null for module context
if (invocationType == null)
invocationType = InternalType.FakeInternalType;
//
// If only accessible to the current class or children
//
if (ma == Modifiers.PRIVATE)
return invocationType.MemberDefinition == parentType.MemberDefinition ||
TypeManager.IsNestedChildOf (invocationType, parentType.MemberDefinition);
if ((ma & Modifiers.INTERNAL) != 0) {
bool b;
var assembly = invocationType == InternalType.FakeInternalType ?
RootContext.ToplevelTypes.DeclaringAssembly :
invocationType.MemberDefinition.DeclaringAssembly;
if (parentType == null) {
b = ((ITypeDefinition) MemberDefinition).IsInternalAsPublic (assembly);
} else {
b = DeclaringType.MemberDefinition.IsInternalAsPublic (assembly);
}
if (b || ma == Modifiers.INTERNAL)
return b;
}
// PROTECTED
if (!TypeManager.IsNestedFamilyAccessible (invocationType, parentType))
return false;
return true;
}