Start
[mono.git] / mcs / mbas / decl.cs
index ff8b249568ddea82e119bb351b35d36d5408d868..87323b762bb6cd32767e0fdb616d492104eb81b6 100644 (file)
@@ -45,11 +45,11 @@ namespace Mono.MonoBASIC {
 
                protected void WarningNotHiding (TypeContainer parent)
                {
-                       Report.Warning (
+                       /*Report.Warning (
                                109, Location,
                                "The member " + parent.MakeName (Name) + " does not hide an " +
                                "inherited member.  The keyword new is not required");
-                                                          
+                       */                                 
                }
 
                void Error_CannotChangeAccessModifiers (TypeContainer parent, MethodInfo parent_method,
@@ -75,26 +75,25 @@ namespace Mono.MonoBASIC {
                                                       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
                                //
@@ -107,26 +106,47 @@ namespace Mono.MonoBASIC {
                                }
                        }
 
-                       if (mb.IsVirtual || mb.IsAbstract){
-                               if ((ModFlags & (Modifiers.NEW | Modifiers.OVERRIDE)) == 0){
+                       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 (
-                                                       114, 2, Location, parent.MakeName (Name) + 
-                                                       " hides inherited member `" + name +
+                                                       40005, 2, Location, parent.MakeName (Name) + 
+                                                       " shadows overridable member `" + name +
                                                        "'.  To make the current member override that " +
-                                                       "implementation, add the override keyword, " +
-                                                       "otherwise use the new keyword");
-                                               ModFlags |= Modifiers.NEW;
+                                                       "implementation, add the overrides keyword." );
+                                               ModFlags |= Modifiers.SHADOWS;
                                        }
                                }
-                       } else {
-                               if ((ModFlags & (Modifiers.NEW | Modifiers.OVERRIDE)) == 0){
+                       } 
+                       else {
+                               if ((ModFlags & (Modifiers.NEW | Modifiers.OVERRIDE | 
+                                       Modifiers.SHADOWS)) == 0){
                                        if (Name != "Finalize"){
                                                Report.Warning (
-                                                       108, 1, Location, "The keyword new is required on " +
+                                                       40004, 1, Location, "The keyword Shadows is required on " +
                                                        parent.MakeName (Name) + " because it hides " +
                                                        "inherited member `" + name + "'");
-                                               ModFlags |= Modifiers.NEW;
+                                               ModFlags |= Modifiers.SHADOWS;
                                        }
                                }
                        }
@@ -306,10 +326,7 @@ namespace Mono.MonoBASIC {
                /// </summary>
                public string LookupAlias (string name)
                {
-                       if (Namespace != null)
-                               return Namespace.LookupAlias (name);
-                       else
-                               return null;
+                       return RootContext.SourceBeingCompiled.LookupAlias (name);
                }
                
                // 
@@ -447,7 +464,7 @@ namespace Mono.MonoBASIC {
                        
                        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;
                        }
@@ -542,13 +559,13 @@ namespace Mono.MonoBASIC {
                                //
                                // Now check the using clause list
                                //
-                               ArrayList using_list = ns.UsingTable;
-                               
-                               if (using_list == null)
-                                       continue;
+                               ICollection imports_list = RootContext.SourceBeingCompiled.ImportsTable;\r
+\r
+                               if (imports_list == null)\r
+                                       continue;\r
 
                                Type match = null;
-                               foreach (Namespace.UsingEntry ue in using_list){
+                               foreach (SourceBeingCompiled.ImportsEntry ue in imports_list){
                                        match = LookupInterfaceOrClass (ue.Name, name, out error);
                                        if (error)
                                                return null;