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) \r
+ {
+ 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 " +
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;
}