Bugzilla – Bug 321119
[GMCS] Mutually recursive Generics with inheritance
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by karl@waclawek.net 2006-05-12 12:29:32 MST ---- Description of Problem: I have a source file with mutually recursive generics that compiles under MS csc (.NET 2.0, VS 2005), but not under gmcs (Mono 1.1.15 Beta 2). Below is a simplified version of this file: === begin source file test.cs === using System; namespace Test { public class ThisBaseClass<A, B, C> where A: ThisBaseClass<A, B, C> where B: ThatBaseClass<B, A, C>, new() where C: class { } public class ThatBaseClass<B, A, C> where B: ThatBaseClass<B, A, C>, new() where A: ThisBaseClass<A, B, C> where C: class { public ThatBaseClass() {} } public class ThisClass<A, B, C>: ThisBaseClass<A, B, C> where A: ThisClass<A, B, C> where B: ThatClass<B, A, C>, new() where C: class { } public class ThatClass<B, A, C>: ThatBaseClass<B, A, C> where B: ThatClass<B, A, C>, new() where A: ThisClass<A, B, C> where C: class { } public class ThisClass: ThisClass<ThisClass, ThatClass, object> { } public class ThatClass: ThatClass<ThatClass, ThisClass, object> { public ThatClass() {} } } === end source file === The error message generated by gmcs is: [kwaclaw@newdev SAXExpat]$ gmcs /t:library test.cs test.cs(42,27): error CS0309: The type `Test.ThatClass' must be convertible to `Test.ThatClass<Test.ThatClass,Test.ThisClass,object>' in order to use it as parameter `B' in the generic type or method `Test.ThatClass<B,A,C>' test.cs(29,16):: `Test.ThatClass<B,A,C>', name of symbol related to previous error test.cs(42,16):: `Test.ThatClass', name of symbol related to previous error test.cs(37,27): error CS0309: The type `Test.ThisClass' must be convertible to `Test.ThisClass<Test.ThisClass,Test.ThatClass,object>' in order to use it as parameter `A' in the generic type or method `Test.ThisClass<A,B,C>' test.cs(21,16):: `Test.ThisClass<A,B,C>', name of symbol related to previous error test.cs(37,16):: `Test.ThisClass', name of symbol related to previous error Compilation failed: 2 error(s), 0 warnings ---- Additional Comments From miguel@ximian.com 2006-05-14 15:39:31 MST ---- Martin, can you look at this? ---- Additional Comments From martin@ximian.com 2006-06-19 08:11:27 MST ---- Fixed in SVN; added gtest-273.cs. Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>Fedora Core 4</cf_op_sys_details> Unknown bug field "cf_version_details" encountered while moving bug <cf_version_details>1.1.15 Beta 2</cf_version_details>