[Mono-dev] Pretty bad compiler regression in 2.4, and 2.6 with nullable generics and interfaces

Arne Claassen arnec at mindtouch.com
Fri Oct 2 13:37:48 EDT 2009

I filed this here:



namespace Repro {
     class Program {
         public static void Main(string[] args) { }
     interface InterfaceWithGenericMethod {
         T? GenericMethod<T>() where T : struct;

     public class DerivedClass : InterfaceWithGenericMethod {
         public T? GenericMethod<T>() where T : struct {
             return null;

produces the below on 2.4 and 2.6:
Program.cs(10,19): error CS0425: The constraints for type parameter  
`T' of method `Repro.DerivedClass.GenericMethod<T>()' must match the  
constraints for type parameter `T' of interface method  
`Repro.InterfaceWithGenericMethod.GenericMethod<T>()'. Consider using  
an explicit interface implementation instead
Program.cs(6,12): (Location of the symbol related to previous error)

This used to work in 1.9.1, and i think 2.0. Also works on .NET. Seems  
like it's not able to match up the constraints between the interface  
and the implementation.

Arne Claassen

San Diego, CA

More information about the Mono-devel-list mailing list