Bugzilla – Bug 320094
[GMCS] error for simple recursive generic type
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by bcs26@cornell.edu 2006-01-18 16:09:49 MST ---- The attached RecType.cs test case compiles without errors. The attached RecTypeUse.cs test case, however, fails to compile with the following error: $ gmcs RecType.cs RecType.cs(17,24): error CS0309: The type `RealFoo<int>' must be convertible to `Foo<T>' in order to use it as parameter `T' in the generic type or method `Bar<T>' RecType.cs(13,14):: `Bar<T>', name of symbol related to previous error RecType.cs(7,14):: `RealFoo<E>', name of symbol related to previous error Compilation failed: 1 error(s), 0 warnings Using mono 1.1.12.1 under Gentoo on amd64. I'm actually not sure if either of these test cases should compile, but it seems as if either both should (what I would expect), or neither should (if C# disallows generic types of this form). If the existing behavior is correct, then the gmcs error message is misleading, since the types listed are in fact convertible. ---- Additional Comments From bcs26@cornell.edu 2006-01-18 16:10:52 MST ---- Created an attachment (id=169142) first test case (compiles) ---- Additional Comments From bcs26@cornell.edu 2006-01-18 16:11:15 MST ---- Created an attachment (id=169143) second test case (doesn't compile) ---- Additional Comments From martin@ximian.com 2006-01-21 09:18:39 MST ---- Miguel, when reassigning bugs to me, could you please also set the priority to a reasonable value ? ---- Additional Comments From miguel@ximian.com 2006-01-25 14:38:54 MST ---- Set to a reasonable value. ---- Additional Comments From martin@ximian.com 2006-03-22 08:15:46 MST ---- First test case: ====== public interface Foo<T> { } public abstract class FooBase<T> : Foo<T> { } public class RealFoo<E> : FooBase<RealFoo<E>> { public void ItsConvertible() { Foo<RealFoo<E>> f = this; } } ===== ---- Additional Comments From martin@ximian.com 2006-03-22 08:16:09 MST ---- Second test case: ====== public interface Foo<T> { } public abstract class FooBase<T> : Foo<T> { } public class RealFoo<E> : FooBase<RealFoo<E>> { public void ItsConvertible() { Foo<RealFoo<E>> f = this; } } public class Bar<T> where T : Foo<T> { } public class RealBar : Bar<RealFoo<int>> { } ====== ---- Additional Comments From martin@ximian.com 2006-03-22 08:21:35 MST ---- I can't reproduce this anymore. Imported an attachment (id=169142) Imported an attachment (id=169143) Unknown operating system unknown. Setting to default OS "Other".