Bugzilla – Bug 314771
NotOverridable Subs
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by jwezel@compumaster.de 2004-05-19 03:51:41 MST ---- Description of Problem: NotOverridable Subs are not supported currently, see this example: public class myTestApp public shared sub Main() System.Console.WriteLine("hello world!") System.Console.ReadLine() end sub notoverridable sub ebbes () system.console.writeline("") end sub end class That is the compilation error: Cannot be declared NotOverridable since this method is not maked as Overrides (0,0) : error failed: 2 Error(s), 0 warnings How often does this happen? Everytime ---- Additional Comments From banirban@novell.com 2004-06-03 05:51:14 MST ---- This doesn't look like a bug rather a check provided by mbas compiler. NotOveridable will work if implemented it in following fashion Class B Public Overridable Sub F1() End Sub End Class Class D Inherits B Public NotOverridable Overrides Sub F1() End Sub End Class If a class is derived from another which contains a Overridable sub or function then that particular sub/function can be declared NotOverridable to prevent Overriding in the next level. By default every public function/sub is NotOverridable hence the compiler doesn’t entertain specifying the same modifier explicitly and returns the exception what you are getting.