Bug 22131 - CS0425. Can't implement interface method with generic argument when where requirement is an interface
Summary: CS0425. Can't implement interface method with generic argument when where req...
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 3.4.0
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2014-08-15 04:48 UTC by Anders Marchsteiner
Modified: 2014-08-16 08:50 UTC (History)
2 users (show)

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


Attachments

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

Note You need to log in before you can comment on or make changes to this bug.