Bugzilla – Bug 319967
[GMCS] Generic method type parameter problem across assemblies
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by sestoft@dina.kvl.dk 2006-01-05 17:57:29 MST ---- Description of Problem: When compiling the program below in one source file, it compiles fine with gmcs 1.1.12.1 as it should. When compiling MyList<T> as a library, the compilation of MyTest fails. Steps to reproduce the problem: 1. Compile gmcs /t:library https://bugzilla.novell.com/show_bug.cgi?id=MONO20a.cs 2. Compile gmcs /r:https://bugzilla.novell.com/show_bug.cgi?id=MONO20a.dll https://bugzilla.novell.com/show_bug.cgi?id=MONO20b.cs 3. Observe unexpected error message Actual Results: https://bugzilla.novell.com/show_bug.cgi?id=MONO20b.cs(8,5): error CS0309: The type `string' must be convertible to `T' inorder to use it as parameter `U' in the generic type or method `MyList<string>.AddAll<U>(IEnumerable<U>)' /home/sestoft/cs/https://bugzilla.novell.com/show_bug.cgi?id=MONO20a.dll: `MyList<string>.AddAll<U>(IEnumerable<U>)', nameof symbol related to previous error /usr/local/mono-1.1.12.1/lib/mono/2.0/mscorlib.dll: `string', name of symbol related to previous error Compilation failed: 1 error(s), 0 warnings Expected Results: No compiler error. Works with csc 2.0. Additional Information: // Program https://bugzilla.novell.com/show_bug.cgi?id=MONO20a.cs: using System.Collections.Generic; public class MyList<T> : List<T> { public void AddAll<U>(IEnumerable<U> xs) where U : T { foreach (T x in xs) Add(x); } } // Program https://bugzilla.novell.com/show_bug.cgi?id=MONO20b.ca: using System; class GettingStarted { public static void Main(String[] args) { MyList<String> names = new MyList<String>(); names.AddAll<String>(new String[] { "Hoover", "Roosevelt", "Truman", "Eisenhower", "Kennedy" }); } } ---- Additional Comments From martin@ximian.com 2006-01-15 21:09:27 MST ---- Fixed in SVN. Unknown operating system unknown. Setting to default OS "Other".