[Mono-bugs] [Bug 62275][Nor] New - delegate dispatch to a base class inconsistent with ms.net

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 2 Aug 2004 08:19:52 -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 ianm@activestate.com.

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

--- shadow/62275	2004-08-02 08:19:52.000000000 -0400
+++ shadow/62275.tmp.24247	2004-08-02 08:19:52.000000000 -0400
@@ -0,0 +1,99 @@
+Bug#: 62275
+Product: Mono: Compilers
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: ianm@activestate.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: delegate dispatch to a base class inconsistent with ms.net
+
+Description of Problem:
+If you create a delegate instance using a method from the base class of the
+current instance the compiler will use the override from the current
+instance instead ( if it exists )
+
+Steps to reproduce the problem:
+1. Compile the following code sample with mcs
+using System;
+
+namespace test {
+    
+    class myBase {
+         public virtual int Read() {            
+            Console.WriteLine("MyBase Read Method");
+            return 1;
+        }
+    }
+    
+    class myTest : myBase {
+        
+        delegate int TestDelegate();
+        private TestDelegate ReadChar = null;
+        
+        
+        public myTest(){
+            ReadChar = new TestDelegate(base.Read);
+        }
+        public override int Read() {           
+            Console.WriteLine("myTest Read Method");
+            return ReadChar();
+        }
+        
+        static void Main(string[] args){
+            myTest test = new myTest();
+            test.Read();
+        }
+    }
+}
+
+
+Actual Results:
+when you run the generated exe it will infinite loop as the delegate
+dispatches to the lowest level Read method:
+
+H:\dev\test\csharp>mono delegateTest.exe
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+myTest Read Method
+
+Expected Results:
+
+H:\dev\test\csharp>mono delegateTest.exe
+myTest Read Method
+MyBase Read Method
+
+How often does this happen? 
+consistently
+
+Additional Information:
+note that compiling the same code with csc gives correct results on both
+mono and .net runtimes. Compiling with mcs gives incorrect on both -
+leading me to belive that its a code generation issue with mcs.