Bugzilla – Bug 319243
[PATCH] [GMCS] methods with different generic arity
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by atsushi@ximian.com 2005-10-09 04:25:16 MST ---- gmcs cannot differentiate such methods that have the same args, same type body name, but have diffrent generic arguments on the return type. -------- public interface Ret {} public interface Ret<T> {} public abstract class BaseClass { public virtual Ret Foo () { return null; } public virtual Ret<T> Foo<T> () { return null; } } public class DerivedClass : BaseClass { public override Ret Foo () { return null; } public override Ret<T> Foo<T> () { return null; } } Actual Results: overload-override.cs(12,22): error CS0508: `DerivedClass.Foo()': return type must be `Ret<T>' to match overridden member `BaseClass.Foo()' overload-override.cs(7,26):: `BaseClass.Foo()', name of symbol related to previous error Compilation failed: 1 error(s), 0 warnings Expected Results: no error (except for entrypoint not found). How often does this happen? consistently. ---- Additional Comments From atsushi@ximian.com 2005-10-09 06:23:41 MST ---- With the experiment below, I guess this is a compiler problem. -------- using System; public class Test { public Ret ret; public static void Main () { Type t1 = typeof (Test).GetField ("ret").FieldType; Type t2 = typeof (Ret<int>).GetGenericTypeDefinition (); Console.WriteLine (t1 == t2); Console.WriteLine (t1); Console.WriteLine (t2.GetGenericTypeDefinition ()); } } public interface Ret { } public interface Ret<T> {} ---- $ mono gentypes.exe False Ret Ret`1[T] $ ./gentypes False Ret Ret`1[T] ---- Additional Comments From atsushi@ximian.com 2005-10-19 00:29:24 MST ---- Created an attachment (id=168646) proposed fix ---- Additional Comments From martin@ximian.com 2005-10-19 14:04:29 MST ---- From looking at the summary, I almost closed this as NOTABUG. ---- Additional Comments From martin@ximian.com 2005-10-19 14:07:58 MST ---- Your patch look good. Note that it's not allowed to have two methods with the same parameter types *and* the same generic arity - so instead of actually comparing the generic parameters, it'd be enough to check for the arity. ---- Additional Comments From atsushi@ximian.com 2005-10-19 15:54:44 MST ---- Ok, the patch is commited, removing individual comparison of parameter constraints. Imported an attachment (id=168646) Unknown operating system unknown. Setting to default OS "Other".