Bug 22131

Summary: CS0425. Can't implement interface method with generic argument when where requirement is an interface
Product: [Mono] Compilers Reporter: Anders Marchsteiner <alm.anma>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: alm.anma, mono-bugs+mono
Priority: ---    
Version: 3.4.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
See Also: https://bugzilla.xamarin.com/show_bug.cgi?id=495
https://bugzilla.xamarin.com/show_bug.cgi?id=9443
Tags: Is this bug a regression?: ---
Last known good build:

Description Anders Marchsteiner 2014-08-15 04:48:15 UTC
/********** Test.cs **********/
interface IX<TI>
{
    void M<TO>()
        where TO : TI;
}

interface IY
{

}

class A : IX<IY>
{
    public void M<TO>()
        where TO : IY
    {

    }
}
/********** Test.cs **********/

On Mono 3.6 (3.4 had the same issue - Havn't tested earlier versions than that):

mcs --version
 -> Mono C# compiler version 3.6.0.0

mcs -target:library Test.cs
 -> Test.cs(12,7): error CS0425: The constraints for type parameter `TO' of method `A.M<TO>()' must match the constraints for type parameter `TO' of interface method `IX<IY>.M<TO>()'. Consider using an explicit interface implementation instead
 -> Test.cs(14,17): (Location of the symbol related to previous error)
 -> Test.cs(3,10): (Location of the symbol related to previous error)
 -> Compilation failed: 1 error(s), 0 warnings

On Microsoft .NET:

csc /target:library Test.cs
 -> Microsoft (R) Visual C# Compiler version 4.0.30319.33440
 -> for Microsoft (R) .NET Framework 4.5
 -> Copyright (C) Microsoft Corporation. All rights reserved.

Microsoft .NET compiles successfully and produces an assemblie. Mono fails.
Comment 1 Anders Marchsteiner 2014-08-15 05:05:11 UTC
Btw. The following code compiles just fine:

/********** Test.cs **********/
interface IX<TI>
{
    void M<TO>()
        where TO : TI;
}

class IY
{

}

class A : IX<IY>
{
    public void M<TO>()
        where TO : IY
    {

    }
}
/********** Test.cs **********/

The only change is that IY is a class and not an interface.
Comment 2 Marek Safar 2014-08-16 08:50:13 UTC
Fixed in master