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)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

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