/// Base representation for members. This is only used to keep track
/// of Name, Location and Modifier flags.
/// </summary>
- public abstract class MemberCore {
+ public abstract class MemberCore : Attributable
+ {
/// <summary>
/// Public name
/// </summary>
/// </summary>
public readonly Location Location;
- public MemberCore (string name, Location loc)
+ public MemberCore (string name, Attributes attrs, Location loc)
+ : base (attrs)
{
Name = name;
Location = loc;
// FIXME: report the old/new permissions?
//
Report.Error (
- 507, Location, parent.MakeName (Name) +
+ 31048, Location, parent.MakeName (Name) +
": can't change the access modifiers when overriding inherited " +
"member `" + name + "'");
}
MethodInfo mb, string name)
{
bool ok = true;
-
+
if ((ModFlags & Modifiers.OVERRIDE) != 0){
- if (!(mb.IsAbstract || mb.IsVirtual)){
+ // Now we check that the overriden method is not final
+ if (mb.IsFinal)
+ {
+ Report.Error (30267, Location, parent.MakeName (Name) + " : cannot " +
+ "override inherited member `" + name +
+ "' because it is NotOverridable.");
+ ok = false;
+ }
+ else if (!(mb.IsAbstract || mb.IsVirtual)){
Report.Error (
- 506, Location, parent.MakeName (Name) +
- ": cannot override inherited member `" +
+ 31086, Location, parent.MakeName (Name) +
+ ": Cannot override inherited member `" +
name + "' because it is not " +
- "virtual, abstract or override");
+ "declared as Overridable");
ok = false;
}
- // Now we check that the overriden method is not final
-
- if (mb.IsFinal) {
- Report.Error (239, Location, parent.MakeName (Name) + " : cannot " +
- "override inherited member `" + name +
- "' because it is sealed.");
- ok = false;
- }
-
//
// Check that the permissions are not being changed
//
}
}
- if (mb.IsVirtual || mb.IsAbstract){
+ if ((ModFlags & ( Modifiers.NEW | Modifiers.SHADOWS | Modifiers.OVERRIDE )) == 0) {
+ if ((ModFlags & Modifiers.NONVIRTUAL) != 0) {
+ Report.Error (31088, Location,
+ parent.MakeName (Name) + " cannot " +
+ "be declared NotOverridable since this method is " +
+ "not marked as Overrides");
+ }
+ }
+
+ if (mb.IsAbstract) {
+ if ((ModFlags & (Modifiers.OVERRIDE)) == 0) {
+ if (Name != "Finalize") {
+ Report.Error (
+ 31404, Location,
+ name + " cannot Shadows the method " +
+ parent.MakeName (Name) + " since it is declared " +
+ "'MustOverride' in base class");
+ }
+ }
+ }
+ else if (mb.IsVirtual){
if ((ModFlags & (Modifiers.NEW | Modifiers.OVERRIDE | Modifiers.SHADOWS)) == 0){
if (Name != "Finalize"){
Report.Warning (
ModFlags |= Modifiers.SHADOWS;
}
}
- } else {
+ }
+ else {
if ((ModFlags & (Modifiers.NEW | Modifiers.OVERRIDE |
- Modifiers.SHADOWS)) == 0)
- {
+ Modifiers.SHADOWS)) == 0){
if (Name != "Finalize"){
Report.Warning (
40004, 1, Location, "The keyword Shadows is required on " +
/// </summary>
NameExists,
- /// <summary>
- /// Returned if the declation being added to the
- /// name space clashes with its container name.
- ///
- /// The only exceptions for this are constructors
- /// and static constructors
- /// </summary>
- EnclosingClash,
-
/// <summary>
/// Returned if a constructor was created (because syntactically
/// it looked like a constructor) but was not (because the name
TypeContainer parent;
- public DeclSpace (TypeContainer parent, string name, Location l)
- : base (name, l)
+ public DeclSpace (TypeContainer parent, string name, Attributes attrs, Location l)
+ : base (name, attrs, l)
{
Basename = name.Substring (1 + name.LastIndexOf ('.'));
defined_names = new Hashtable ();
/// </summary>
protected AdditionResult IsValid (string name)
{
- if (name == Basename)
- return AdditionResult.EnclosingClash;
-
if (defined_names.Contains (name))
return AdditionResult.NameExists;
/// </summary>
protected void DefineName (string name, object o)
{
- defined_names.Add (name, o);
+ try {
+ defined_names.Add (name, o);
+ }
+ catch (ArgumentException exp) {
+ Report.Error (30260, /*Location,*/
+ "More than one defination with same name '" + name +
+ "' is found in the container '" + Name + "'");
+ }
+
}
/// <summary>
Expression d = e.Resolve (type_resolve_ec, ResolveFlags.Type);
if (d == null || d.eclass != ExprClass.Type){
if (!silent && errors == Report.Errors){
- Report.Error (246, loc, "Cannot find type `"+ e.ToString () +"'");
+ Report.Error (30002, loc, "Cannot find type `"+ e.ToString () +"'");
}
return null;
}
Expression d = e.Resolve (type_resolve_ec, ResolveFlags.Type);
if (d == null || d.eclass != ExprClass.Type){
if (!silent){
- Report.Error (246, loc, "Cannot find type `"+ e +"'");
+ Report.Error (30002, loc, "Cannot find type `"+ e +"'");
}
return null;
}
t = parent.DefineType ();
if (t == null){
- Report.Error (146, Location, "Class definition is circular: `"+name+"'");
+ Report.Error (30256, Location, "Class definition is circular: `"+name+"'");
error = true;
return null;
}
//
// Now check the using clause list
//
- ICollection imports_list = RootContext.SourceBeingCompiled.ImportsTable;\r
-\r
- if (imports_list == null)\r
- continue;\r
+ ICollection imports_list = RootContext.SourceBeingCompiled.ImportsTable;
+
+ if (imports_list == null)
+ continue;
Type match = null;
foreach (SourceBeingCompiled.ImportsEntry ue in imports_list){
public abstract MemberCache MemberCache {
get;
}
+
+ public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
+ {
+ try {
+ TypeBuilder.SetCustomAttribute (cb);
+ } catch (System.ArgumentException e) {
+ Report.Warning (-21, a.Location,
+ "The CharSet named property on StructLayout\n"+
+ "\tdoes not work correctly on Microsoft.NET\n"+
+ "\tYou might want to remove the CharSet declaration\n"+
+ "\tor compile using the Mono runtime instead of the\n"+
+ "\tMicrosoft .NET runtime\n"+
+ "\tThe runtime gave the error: " + e);
+ }
+ }
}
+
/// <summary>
/// This is a readonly list of MemberInfo's.
/// </summary>
IDictionaryEnumerator it = parent.member_hash.GetEnumerator ();
while (it.MoveNext ()) {
- hash [it.Key] = ((ArrayList) it.Value).Clone ();
+ ArrayList al = (ArrayList) it.Value;
+ // Constructors are never inherited and all have the same key
+ if ((((CacheEntry)al [0]).EntryType & EntryType.Constructor) == 0)
+ hash [it.Key] = ((ArrayList) it.Value).Clone ();
}
return hash;
void AddMembers (MemberTypes mt, BindingFlags bf, IMemberContainer container)
{
MemberList members = container.GetMembers (mt, bf);
- BindingFlags new_bf = (container == Container) ?
+ /*BindingFlags new_bf = (container == Container) ?
bf | BindingFlags.DeclaredOnly : bf;
-
+ */
foreach (MemberInfo member in members) {
string name = member.Name;
// iteration of this loop if there are no members with the name we're
// looking for in the current class).
if (entry.Container != current) {
- if (declared_only || DoneSearching (list))
+ //if (declared_only || DoneSearching (list))
+ if (declared_only)
break;
current = entry.Container;