Bug 319243 (MONO76382) - [PATCH] [GMCS] methods with different generic arity
Summary: [PATCH] [GMCS] methods with different generic arity
Status: RESOLVED FIXED
Alias: MONO76382
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Martin Baulig
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-09 11:25 UTC by Atsushi Enomoto
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
proposed fix (2.88 KB, patch)
2005-10-19 07:29 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:34:10 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".