[Mono-bugs] [Bug 59246][Nor] New - Mix of non-override and override overloads in a class

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 28 May 2004 09:25:26 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by vguzev@yandex.ru.

http://bugzilla.ximian.com/show_bug.cgi?id=59246

--- shadow/59246	2004-05-28 09:25:26.000000000 -0400
+++ shadow/59246.tmp.12173	2004-05-28 09:25:26.000000000 -0400
@@ -0,0 +1,106 @@
+Bug#: 59246
+Product: Mono: Compilers
+Version: unspecified
+OS: Red Hat 9.0
+OS Details: Linux skif 2.4.25 #2 SMP Fri Apr 23 14:03:00 MSD 2004 i686 athlon i386 GNU/Linux
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: vguzev@yandex.ru               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Mix of non-override and override overloads in a class
+
+I've found some differences between MS .Net and Mono behaviour.
+
+Here's a little example (from RSDN forum):
+8<---------------------------------------------------------
+using System;
+
+namespace TestMethods
+{
+ class Class1
+ {
+  static void Main(string[] args)
+  {
+   TestClass testClass = new TestClass();
+   testClass.AddItem("", new TestParam());
+   testClass.AddItem("", new ParamClass());
+
+   BaseClass baseClass = testClass as BaseClass;
+   baseClass.AddItem("", new TestParam());
+   baseClass.AddItem("", new ParamClass());
+  }
+ }
+
+ public class ParamClass {}
+
+ public class TestParam : ParamClass {}
+
+ public abstract class BaseClass
+ {
+  public abstract void AddItem(String name, ParamClass val);
+ }
+
+ public class TestClass : BaseClass
+ {
+  public void AddItem(String name, Object val)
+  {
+   Console.WriteLine("Method with 'Object val' called");
+  }
+
+  public override void AddItem(String name, ParamClass val)
+  {
+   Console.WriteLine("Method with 'ParamClass val' called");
+  }
+ }
+}
+8<---------------------------------------------------------
+
+MS.Net prints the following:
+8<---------------------------------------------------------
+Method with 'Object val' called
+Method with 'Object val' called
+Method with 'ParamClass val' called
+Method with 'ParamClass val' called
+8<---------------------------------------------------------
+
+Mono prints:
+8<---------------------------------------------------------
+Method with 'ParamClass val' called
+Method with 'ParamClass val' called
+Method with 'ParamClass val' called
+Method with 'ParamClass val' called
+8<---------------------------------------------------------
+
+
+Robert Remen at maillist says:
+8<---------------------------------------------------------
+The implementation of mono compiler is wrong. If you have a mix of
+non-override and override overloads in a class, then the non-override
+overload must take precedence (at compile time).
+
+From the C# Language Specification:
+
+- in section 7.4.2:
+
+"For example, the set of candidates for a method invocation does not
+include methods marked override (Section 7.3), and methods in a base
+class are not candidates if any method in a derived class is applicable
+(Section 7.5.5.1)."
+
+-in section 7.5.5.1:
+
+"The intuitive effect of the resolution rules described above is as
+follows: To locate the particular method invoked by a method invocation,
+start with the type indicated by the method invocation and proceed up
+the inheritance chain until at least one applicable, accessible,
+non-override method declaration is found. Then perform overload
+resolution on the set of applicable, accessible, non-override methods
+declared in that type and invoke the method thus selected."
+8<---------------------------------------------------------