Bug 12352 - IEnumerable Cast - Problem
Summary: IEnumerable Cast - Problem
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2013-05-22 15:47 UTC by Ruda
Modified: 2013-05-23 03:54 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

About (911 bytes, text/plain)
2013-05-22 15:48 UTC, Ruda

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Ruda 2013-05-22 15:47:54 UTC
Please take the test this code:
It should work, but does not work on Mono (works in Visual Studio).

Error CS1502: The best overloaded method match for 'Dados.Test.Add(System.Collections.Generic.IEnumerable<Dados.Test.Master>)' has some invalid arguments
Error CS1503: Argument `#1' cannot convert `System.Collections.Generic.IEnumerable<Dados.Test.OverMaster>' expression to type `System.Collections.Generic.IEnumerable<Dados.Test.Master>'

    public static class Test
        public class Master { }
        public class OverMaster : Master { }

        public static void Test2()
            IEnumerable<OverMaster> ds = new List<OverMaster>();


        public static void Add(IEnumerable<Master> list) { }
Comment 1 Ruda 2013-05-22 15:48:18 UTC
Created attachment 4008 [details]
Comment 2 Marek Safar 2013-05-23 03:54:59 UTC
That's expected if you are using XI because IEnumerable<> is not variant. You need XI based on 3.0 mono which has variant version of IEnumerable<> to support this code.