[Mono-dev] Generic Constraints Regression in 2.8
Tom Philpot
tom.philpot at logos.com
Mon Nov 15 13:38:01 EST 2010
https://bugzilla.novell.com/show_bug.cgi?id=653710
From: Marek Safar <marek.safar at gmail.com<mailto:marek.safar at gmail.com>>
Date: Mon, 15 Nov 2010 06:16:57 -0800
To: "mono-devel-list at lists.ximian.com<mailto:mono-devel-list at lists.ximian.com>" <mono-devel-list at lists.ximian.com<mailto:mono-devel-list at lists.ximian.com>>
Subject: Re: [Mono-dev] Generic Constraints Regression in 2.8
Hello,
Could you please fill a bug report.
Thanks
Marek
Except that Y is constrained to be of type Z and so is guaranteed to be a reference type.
On Mon, Nov 15, 2010 at 12:30 AM, Bojan Rajkovic <severedcross at gmail.com<mailto:severedcross at gmail.com>> wrote:
On Nov 14, 2010, at 10:16 PM, Tom Philpot wrote:
The following code compiled with a warning on Mono 2.7 (as of 147679) but has an error in 2.8.
namespace Application
{
public class Z {}
public class A<X, Y>
where Y : Z
where X : Y
{
protected void SomeOperation(Y y)
{
X x = y as X;
}
}
public class Foo { public static void Main() {} }
}
/opt/mono-2.8/bin/gmcs CS0413Regression.cs
CS0413Regression.cs(12,33): error CS0413: The `as' operator cannot be used with a non-reference type parameter `X'. Consider adding `class' or a reference type constraint
Compilation failed: 1 error(s), 0 warnings
/opt/mono-r147679/bin/gmcs CS0413Regression.cs
CS0413Regression.cs(12,27): warning CS0219: The variable `x' is assigned but its value is never used
Compilation succeeded - 1 warning(s)
The error message here is the correct thing to do—as casts are only valid with reference types, because they can result in null, which is invalid for a value type. If this raised only a warning in gmcs earlier, it was a bug.
—Bojan
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com<mailto:Mono-devel-list at lists.ximian.com>
http://lists.ximian.com/mailman/listinfo/mono-devel-list
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com<mailto:Mono-devel-list at lists.ximian.com>
http://lists.ximian.com/mailman/listinfo/mono-devel-list
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com<mailto:Mono-devel-list at lists.ximian.com>http://lists.ximian.com/mailman/listinfo/mono-devel-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20101115/aead6bcb/attachment.html
More information about the Mono-devel-list
mailing list