Bugzilla – Bug 319399
[GMCS] consider base interfaces for CS0309
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by atsushi@ximian.com 2005-10-25 14:09:50 MST ---- gmcs does not seem to consider base interfaces of the constrained type parameters on CS0309 computation. In the code below, K is IBar, thus it should be regarded as to implement IFoo. So no CS0309 error should happen. (I'm not 100% sure if this understanding is right; it might be regarded as a covariant.) interface IFoo {} interface IBar : IFoo {} class Mona<T> where T : IFoo {} class Test { public Mona<K> GetMona<K> () where K : IBar { return new Mona<K> (); } public static void Main () {} } Actual Results: constraint-baseifaces.cs(8,9): error CS0309: The type `K' must be convertible to `IFoo' in order to use it as parameter `T' in the generic type or method `Mona`1<T>' Compilation failed: 1 error(s), 0 warnings Expected Results: no error. How often does this happen? consistently. Additional Information: To my understanding, both of this generic type and this generic method are (should be) marked as NonVariant. ---- Additional Comments From martin@ximian.com 2005-10-25 14:40:25 MST ---- I still don't quite understand the concept of variance/co-variance, but this should compile fine. Should be easy to fix. ---- Additional Comments From martin@ximian.com 2005-10-25 14:48:08 MST ---- Fixed in SVN. Unknown operating system unknown. Setting to default OS "Other".