[Mono-bugs] [Bug 59209][Maj] New - Lookup rules incorrectly computed.

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 27 May 2004 16:22:56 -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 miguel@ximian.com.

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

--- shadow/59209	2004-05-27 16:22:56.000000000 -0400
+++ shadow/59209.tmp.1906	2004-05-27 16:22:56.000000000 -0400
@@ -0,0 +1,90 @@
+Bug#: 59209
+Product: Mono: Compilers
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: miguel@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Lookup rules incorrectly computed.
+
+The following sample:
+
+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");
+  }
+ }
+}
+
+Should print:
+Method with 'Object val' called
+Method with 'Object val' called
+Method with 'ParamClass val' called
+Method with 'ParamClass val' called
+
+We print:
+Method with 'ParamClass val' called
+Method with 'ParamClass val' called
+Method with 'ParamClass val' called
+Method with 'ParamClass val' called
+
+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."