[Mono-bugs] [Bug 553655] New: The compiler fails to recognize fulfilled generic type constraints when another generic parameter is the argument to a nested generic interface two-deep or more
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Sun Nov 8 17:00:18 EST 2009
http://bugzilla.novell.com/show_bug.cgi?id=553655
Summary: The compiler fails to recognize fulfilled generic type
constraints when another generic parameter is the
argument to a nested generic interface two-deep or
more
Classification: Mono
Product: Mono: Compilers
Version: SVN
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: P5 - None
Component: C#
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: lunchtimemama at gmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
If you actually understood that summary, you win the Gold Cookie. Here's what
you really need to know. csc compiles this, gmcs does not:
interface I<T>
{
}
class Foo<T1, T2> where T2 : I<I<T1>>
{
public Foo(T2 t2)
{
}
}
class Bar : I<I<string>>
{
Bar()
{
var foo = new Foo<string, Bar>(this);
}
}
Expected result:
It ought to compile
Actual result:
Error CS0309: The type `Bar' must be convertible to `I<I<T1>>' in order to use
it as parameter `T2' in the generic type or method `Foo<T1,T2>'
The `I<I<T1>>' in this error message should really be `I<I<string>>' (because
that is the type we are using) to which the type `Bar' IS convertible.
NOTE: If we constrain T2 to implement I<T1> and then have Bar implement
I<string>, the code will compile. Also note: gmcs will fail if T1 is used as an
argument to ANY two-deep generic interface (not just I<I<T>>). For example: if
T2 is constrained to I<IEnumerable<T1>> and Bar implements
I<IEnumerable<string>>, the compiler will barf.
--
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