Bug 319137 (MONO76267) - [GMCS][PATCH] using the as operator with a generic parameter
Summary: [GMCS][PATCH] using the as operator with a generic parameter
Status: RESOLVED FIXED
Alias: MONO76267
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.0
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Miguel de Icaza
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-29 05:58 UTC by Duncan Mak
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
generic-as.cs (169 bytes, text/plain)
2005-09-29 05:58 UTC, Thomas Wiest
Details
Proposed patches and tests as a tarball. (1.77 KB, application/octet-stream)
2005-10-01 22:07 UTC, Thomas Wiest
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:32:43 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".