[Mono-dev] Generic Variance Bug

Marek Safar marek.safar at gmail.com
Fri Sep 10 06:39:35 EDT 2010


Hello,
> using mono from trunk, the following code compiles fine:
>
> ==>  buggy.cs<==
> namespace Buggy
> {
>      public interface ITest
>      {
>      }
>
>      public interface ITestSpecialized : ITest
>      {
>      }
>
>      public interface IGeneric<out TTest>  where TTest : ITest
>      {
>          TTest Function();
>      }
>
>      public interface IDerived : IGeneric<ITest>
>      {
>      }
>
>      public abstract class Implementation<TTest>  : IGeneric<TTest>
> where TTest : ITest
>      {
>          public TTest Function()
>          {
>              throw new System.NotImplementedException();
>          }
>      }
>
>      public class MyClass : Implementation<ITestSpecialized>, IDerived
>      {
>      }
> }
>    
This should not actually compile as the interface is not implemented. I 
have pushed a fix for this in master.

Thanks
Marek


More information about the Mono-devel-list mailing list