[Mono-bugs] [Bug 32975][Nor] New - Delegates will not call virtual function overrides

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
29 Oct 2002 13:10:16 -0000


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 jason@379.com.

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

--- shadow/32975	Tue Oct 29 08:10:16 2002
+++ shadow/32975.tmp.24351	Tue Oct 29 08:10:16 2002
@@ -0,0 +1,81 @@
+Bug#: 32975
+Product: Mono/MCS
+Version: unspecified
+OS: other
+OS Details: Red Hat 8.0
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: jason@379.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Delegates will not call virtual function overrides
+
+Description of Problem:
+When a delegate is set to a virtual function in a base class, it will
+always call the base class method, even if an override is available.
+
+
+Steps to reproduce the problem:
+See attached source code.
+
+Actual Results:
+Displays "BaseClass::SomeFunc"
+
+Expected Results:
+Displays "DerivedClass::SomeFunc"
+
+
+How often does this happen? 
+Always.
+
+Additional Information:
+Tested this code with csc/.NET and got expected results.
+
+
+Sample Source Code:
+
+using System;
+
+public class BaseClass
+{
+	delegate void CallbackDelegate();
+	CallbackDelegate m_callback;
+
+	public BaseClass()
+	{
+		m_callback = new CallbackDelegate(SomeFunc);
+	}
+		
+	public void CallFunc()
+	{
+		m_callback();
+	}
+	
+	public virtual void SomeFunc()
+	{
+		Console.WriteLine("BaseClass::SomeFunc\n");
+	}
+}
+
+public class DerivedClass : BaseClass
+{
+	public override void SomeFunc()
+	{
+		Console.WriteLine("DerivedClass::SomeFunc\n");
+	}
+}
+
+class AppClass
+{
+	static void Main()
+	{
+		DerivedClass dc = new DerivedClass();
+		dc.CallFunc();
+	}
+}