Bug 319399 (MONO76557) - [GMCS] consider base interfaces for CS0309
Summary: [GMCS] consider base interfaces for CS0309
Status: RESOLVED FIXED
Alias: MONO76557
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-25 21:09 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

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