[Mono-bugs] [Bug 43359][Wis] New - Overloaded method selection doesn't follow ECMA spec

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Tue, 20 May 2003 04:39:21 -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 skeet@pobox.com.

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

--- shadow/43359	Tue May 20 04:39:21 2003
+++ shadow/43359.tmp.15350	Tue May 20 04:39:21 2003
@@ -0,0 +1,71 @@
+Bug#: 43359
+Product: Mono/MCS
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: skeet@pobox.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Overloaded method selection doesn't follow ECMA spec
+
+Description of Problem:
+
+When an overloaded method name has a better function member in a base class
+than the one in the derived class, the one in the derived class is used.
+
+Steps to reproduce the problem:
+Compile and run the code below:
+
+using System;
+
+public class Base
+{
+    public void Method (int parameter)
+    {
+        Console.WriteLine ("int");
+    }
+}
+
+public class Derived
+{
+    public void Method (double parameter)
+    {
+        Console.WriteLine ("double");
+    }
+    
+    public static void Main()
+    {
+        Derived d = new Derived();
+        d.Method(5);
+    }
+}
+
+
+Actual Results:
+double
+
+Expected Results:
+int
+
+How often does this happen? 
+Always
+
+Additional Information:
+By section 14.3 of the spec, both methods are in the set which is the
+result of the lookup. By section 14.4.2.3, a conversion from int to int is
+better than a conversion from double to int, so the method in the base
+class should be used.
+
+Interestingly, the MS compiler has the same problem.
+
+The same occurs if you use reference types, e.g. string and object, where a
+conversion from string->string should be chosen over a conversion from
+string->object, but isn't.