[Mono-bugs] [Bug 543570] New: CS0425 on generic method with T constrained to struct and return value is nullable (T?)
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Thu Oct 1 13:09:50 EDT 2009
http://bugzilla.novell.com/show_bug.cgi?id=543570
Summary: CS0425 on generic method with T constrained to struct
and return value is nullable (T?)
Classification: Mono
Product: Mono: Compilers
Version: 2.4.x
Platform: Other
OS/Version: All
Status: NEW
Severity: Critical
Priority: P5 - None
Component: C#
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: arnec at mindtouch.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US;
rv:1.9.1) Gecko/20090624 Firefox/3.5
With an interface with a generic method of value T, returning T?, where T is
constrained to a struct, the implementing class will not compile due to CS0245:
"The constraints for type parameter `T' of method
`DerivedClass.GenericMethod<T>()' must match the constraints for type parameter
`T' of interface method `InterfaceWithGenericMethod.GenericMethod<T>()'.
Consider using an explicit interface implementation instead"
This worked in 1.9.2, but does not work on 2.2 or 2.4
Reproducible: Always
Steps to Reproduce:
1. Create program with the following code:
interface InterfaceWithGenericMethod {
T? GenericMethod<T>() where T : struct;
}
public class DerivedClass : InterfaceWithGenericMethod {
public T? GenericMethod<T>() where T : struct {
return null;
}
}
class Program {
public static void Main(string[] args) { }
}
2. compile program
Actual Results:
generic_method_from_interface.cs(6,15): error CS0425: The constraints for type
parameter `T' of method `DerivedClass.GenericMethod<T>()' must match the
constraints for type parameter `T' of interface method
`InterfaceWithGenericMethod.GenericMethod<T>()'. Consider using an explicit
interface implementation instead
generic_method_from_interface.cs(2,8): (Location of the symbol related to
previous error)
Expected Results:
Should compile using mono compiler. Can be compiled with .NET C# compiler and
will execute just fine on mono.
--
Configure bugmail: http://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