[Mono-bugs] [Bug 633277] New: GMCS fails with CS0425 when implementing a generic method from an interface (while same code works on MS.Net)
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Fri Aug 20 12:35:57 EDT 2010
https://bugzilla.novell.com/show_bug.cgi?id=633277
https://bugzilla.novell.com/show_bug.cgi?id=633277#c0
Summary: GMCS fails with CS0425 when implementing a generic
method from an interface (while same code works on
MS.Net)
Classification: Mono
Product: Mono: Compilers
Version: SVN
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: P5 - None
Component: C#
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: pruiz at netway.org
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
Created an attachment (id=384526)
--> (http://bugzilla.novell.com/attachment.cgi?id=384526)
Sample code demostrating the issue
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US)
AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.125 Safari/533.4
Having the following interface defined on project-a:
using System;
namespace DomainServices
{
public interface IServicesContainer
{
void Register<I, T>() where T : I;
void Register<I>(object instance);
}
}
And this implementation on project-b:
using System;
using System.Collections.Generic;
namespace DomainServices
{
public class DictionaryServicesContainer : IServicesContainer
{
public void Register<I, T>()
where T : I
{
throw new NotImplementedException();
}
public void Register<I>(object instance)
{
throw new NotImplementedException();
}
public I Resolve<I>()
{
throw new NotImplementedException();
}
}
}
GMCS will fail during project-b compilation due to CS0425. However the same
code works on ms compiler.
The exacto error is:
/opt/mono-trunk/bin/gmcs /out:b.dll /t:library ServicesContainer.cs
-reference:a.dll
ServicesContainer.cs(9,21): error CS0425: The constraints for type parameter
`T' of method `DomainServices.DictionaryServicesContainer.Register<I,T>()' must
match the constraints for type parameter `T' of interface method
`DomainServices.IServicesContainer.Register<I,T>()'. Consider using an explicit
interface implementation instead
/tmp/a.dll (Location of the symbol related to previous error)
Compilation failed: 1 error(s), 0 warnings
I've attached sample code demostrating the issue.
Reproducible: Always
Steps to Reproduce:
1. gmcs /out:a.dll /t:library IServicesContainer.cs
2. gmcs /out:b.dll /t:library ServicesContainer.cs -reference:a.dll
3. See error from gmcs..
Actual Results:
ServicesContainer.cs(9,21): error CS0425: The constraints for type parameter
`T' of method `DomainServices.DictionaryServicesContainer.Register<I,T>()' must
match the constraints for type parameter `T' of interface method
`DomainServices.IServicesContainer.Register<I,T>()'. Consider using an explicit
interface implementation instead
/tmp/a.dll (Location of the symbol related to previous error)
Compilation failed: 1 error(s), 0 warnings
Expected Results:
code compiled w/o errors.
I've testes this on mono-2.6.7 and it works as expected.. So it seems like a
trunk-only issue. (maight be a regression?)
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list