[Mono-bugs] [Bug 507473] Generic type variance problems

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Jun 2 14:51:37 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=507473

User msafar at novell.com added comment
http://bugzilla.novell.com/show_bug.cgi?id=507473#c2





--- Comment #2 from Marek Safar <msafar at novell.com>  2009-06-02 12:51:33 MDT ---
Test #3

using System;



public interface I<out T>

{

    int Count{ get; }

}



class Foo {}



public class Test : I<string>, I<Foo>

{

    int I<string>.Count

    {

        get { return 1; }

    }



    int I<Foo>.Count

    {

        get { return 2; }

    }

}



public static class Program

{

    static void Main ()

    {

        var col = new Test();



        var test = (I<object>)(object) col;

        Console.WriteLine(test.Count);

    }

}


Mono:

Unhandled Exception: System.InvalidCastException: Cannot cast from source type
to destination type.
  at Program.Main () [0x00000] 

NET:

1

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list