Bugzilla – Bug 319137
[GMCS][PATCH] using the as operator with a generic parameter
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by duncan@ximian.com 2005-09-28 22:58:05 MST ---- Here's a test case: public class Foo<T> { public T Do (object o) { return o as T; } } class Driver { static void Main () { Foo<int> f = new Foo<int> (); f.Do ("something"); } } Expected: generic-as.cs(2,34): error CS0413: The type parameter 'T' cannot be used with the 'as' operator because it does not have a class type constraint nor a 'class' constraint Actual: Compilation Finished. ---- Additional Comments From duncan@ximian.com 2005-09-28 22:58:30 MST ---- Created an attachment (id=168590) generic-as.cs ---- Additional Comments From miguel@ximian.com 2005-10-01 15:07:54 MST ---- Created an attachment (id=168591) Proposed patches and tests as a tarball. ---- Additional Comments From miguel@ximian.com 2005-10-01 15:08:22 MST ---- The above tarball contains tests (negative and positive) and passes the tests on CVS. ---- Additional Comments From martin@ximian.com 2005-10-04 07:51:06 MST ---- Patch looks good, can you please commit ? ---- Additional Comments From miguel@ximian.com 2005-10-04 10:58:00 MST ---- Applied to CVS. Imported an attachment (id=168590) Imported an attachment (id=168591) Unknown operating system unknown. Setting to default OS "Other".