//
public class MemberName {
public readonly string Name;
- public readonly TypeArguments TypeArguments;
+ public TypeArguments TypeArguments;
public readonly MemberName Left;
public readonly Location Location;
if (pm is Indexer.GetIndexerMethod || pm is Indexer.SetIndexerMethod)
pm = null;
- if (pm != null && (pm.Property.Get.IsDummy || pm.Property.Set.IsDummy)) {
+ if (pm != null && pm.Property.AccessorSecond == null) {
Report.Error (840, Location,
"`{0}' must have a body because it is not marked abstract or extern. The property can be automatically implemented when you define both accessors",
GetSignatureForError ());
}
public virtual bool IsUsed {
- get { return (caching_flags & Flags.IsUsed) != 0; }
+ get {
+ return (caching_flags & Flags.IsUsed) != 0;
+ }
}
protected Report Report {
if (OptAttributes == null)
return null;
- Attribute obsolete_attr = OptAttributes.Search (PredefinedAttributes.Get.Obsolete);
+ Attribute obsolete_attr = OptAttributes.Search (Compiler.PredefinedAttributes.Obsolete);
if (obsolete_attr == null)
return null;
case Modifiers.PROTECTED | Modifiers.INTERNAL:
if (al == Modifiers.INTERNAL)
same_access_restrictions = TypeManager.IsThisOrFriendAssembly (Parent.Module.Assembly, p.Assembly);
- else if (al == Modifiers.PROTECTED)
- same_access_restrictions = mc.Parent.IsBaseTypeDefinition (p_parent);
else if (al == (Modifiers.PROTECTED | Modifiers.INTERNAL))
same_access_restrictions = mc.Parent.IsBaseTypeDefinition (p_parent) &&
TypeManager.IsThisOrFriendAssembly (Parent.Module.Assembly, p.Assembly);
+ else
+ goto case Modifiers.PROTECTED;
+
break;
case Modifiers.PRIVATE:
return true;
}
- public virtual ExtensionMethodGroupExpr LookupExtensionMethod (TypeSpec extensionType, string name, int arity, Location loc)
+ public virtual IList<MethodSpec> LookupExtensionMethod (TypeSpec extensionType, string name, int arity, ref NamespaceEntry scope)
{
- return Parent.LookupExtensionMethod (extensionType, name, arity, loc);
+ return Parent.LookupExtensionMethod (extensionType, name, arity, ref scope);
}
public virtual FullNamedExpression LookupNamespaceAlias (string name)
caching_flags &= ~Flags.HasCompliantAttribute_Undetected;
if (OptAttributes != null) {
- Attribute cls_attribute = OptAttributes.Search (PredefinedAttributes.Get.CLSCompliant);
+ Attribute cls_attribute = OptAttributes.Search (Compiler.PredefinedAttributes.CLSCompliant);
if (cls_attribute != null) {
caching_flags |= Flags.HasClsCompliantAttribute;
if (cls_attribute.GetClsCompliantAttributeValue ())
{
if (HasClsCompliantAttribute) {
if (CodeGen.Assembly.ClsCompliantAttribute == null) {
- Attribute a = OptAttributes.Search (PredefinedAttributes.Get.CLSCompliant);
+ Attribute a = OptAttributes.Search (Compiler.PredefinedAttributes.CLSCompliant);
if ((caching_flags & Flags.ClsCompliantAttributeFalse) != 0) {
Report.Warning (3021, 2, a.Location,
"`{0}' does not need a CLSCompliant attribute because the assembly is not marked as CLS-compliant",
}
if (!IsExposedFromAssembly ()) {
- Attribute a = OptAttributes.Search (PredefinedAttributes.Get.CLSCompliant);
+ Attribute a = OptAttributes.Search (Compiler.PredefinedAttributes.CLSCompliant);
Report.Warning (3019, 2, a.Location, "CLS compliance checking will not be performed on `{0}' because it is not visible from outside this assembly", GetSignatureForError ());
return false;
}
}
if (Parent.Parent != null && !Parent.IsClsComplianceRequired ()) {
- Attribute a = OptAttributes.Search (PredefinedAttributes.Get.CLSCompliant);
+ Attribute a = OptAttributes.Search (Compiler.PredefinedAttributes.CLSCompliant);
Report.Warning (3018, 1, a.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 true when this member is a generic in C# terms
- // therefore nested non-generic type of generic type will
- // return false
+ // A nested non-generic type of generic type will return false
//
public bool IsGeneric {
get {
get { return (modifiers & Modifiers.PRIVATE) != 0; }
}
+ public bool IsPublic {
+ get { return (modifiers & Modifiers.PUBLIC) != 0; }
+ }
+
public bool IsStatic {
get {
return (modifiers & Modifiers.STATIC) != 0;
var inflated = (MemberSpec) MemberwiseClone ();
inflated.declaringType = inflator.TypeInstance;
inflated.state |= StateFlags.PendingMetaInflate;
+#if DEBUG
+ if (inflated.ID > 0)
+ inflated.ID = -inflated.ID;
+#endif
return inflated;
}
+ //
+ // Is this member accessible from invocationType
+ //
+ public bool IsAccessible (TypeSpec invocationType)
+ {
+ var ma = Modifiers & Modifiers.AccessibilityMask;
+ if (ma == Modifiers.PUBLIC)
+ return true;
+
+ var parentType = /* this as TypeSpec ?? */ DeclaringType;
+
+ //
+ // If only accessible to the current class or children
+ //
+ if (ma == Modifiers.PRIVATE)
+ return invocationType.MemberDefinition == parentType.MemberDefinition ||
+ TypeManager.IsNestedChildOf (invocationType, parentType);
+
+ if ((ma & Modifiers.INTERNAL) != 0) {
+ var b = TypeManager.IsThisOrFriendAssembly (invocationType == InternalType.FakeInternalType ?
+ CodeGen.Assembly.Builder : invocationType.Assembly, Assembly);
+ if (b || ma == Modifiers.INTERNAL)
+ return b;
+ }
+
+ // PROTECTED
+ if (!TypeManager.IsNestedFamilyAccessible (invocationType, parentType))
+ return false;
+
+ return true;
+ }
+
//
// Returns member CLS compliance based on full member hierarchy
//
public bool CheckAccessLevel (TypeSpec check_type)
{
+// TODO: Use this instead
+// return PartialContainer.Definition.IsAccessible (check_type);
+
TypeSpec tb = PartialContainer.Definition;
check_type = check_type.GetDefinition ();
return null;
// FIXME: Breaks error reporting
- if (!CheckAccessLevel (t))
+ if (!t.IsAccessible (CurrentType))
return null;
return t;