[Mono-list] Bug found: calling virtual func via delegate

J. Perkins jason@379.com
28 Oct 2002 16:48:48 -0500


--=-k39KwKuzw7vBesgxJTkw
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

The attached code illustrates the problem. When compiled with csc, it
will display "DerivedClass::SomeFunc". When compiled with msc, it
displays "BaseClass::SomeFunc".

I didn't see this in bugzilla...is it a known issue?

Jason
379






--=-k39KwKuzw7vBesgxJTkw
Content-Disposition: attachment; filename=delegate_override.cs
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=delegate_override.cs; charset=UTF-8

using System;

public class BaseClass
{
	delegate void CallbackDelegate();
	CallbackDelegate m_callback;

	public BaseClass()
	{
		m_callback =3D new CallbackDelegate(SomeFunc);
	}
	=09
	public void CallFunc()
	{
		m_callback();
	}
=09
	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 =3D new DerivedClass();
		dc.CallFunc();
	}
}

--=-k39KwKuzw7vBesgxJTkw--