[Mono-bugs] [Bug 77548][Nor] New - BadCS0310 error when generic with new() constraint used as own argument

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Feb 13 19:13:29 EST 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by ewtewuo02 at sneakemail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=77548

--- shadow/77548	2006-02-13 19:13:29.000000000 -0500
+++ shadow/77548.tmp.5142	2006-02-13 19:13:29.000000000 -0500
@@ -0,0 +1,49 @@
+Bug#: 77548
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: Mandrake 10
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: ewtewuo02 at sneakemail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: BadCS0310 error when generic with new() constraint used as own argument
+
+Description of Problem:
+
+With the following code:
+
+class Test {
+
+  public class Generic<T> where T : new() {
+    public Generic() {
+      T tmp = new T();
+    }
+  }
+  
+  public Generic<int> okay;
+
+  public Generic<Generic<int>> bad;
+
+  public static void Main() {}
+
+}
+
+I get the following errors from gmcs (from mono 1.1.13.2_0):
+
+generic-bug.cs(11): error CS0310: The type `Test.Generic<int>' must have a
+public parameterless constructor in order to use it as parameter `T' in the
+generic type or method `Test.Generic<T>'
+generic-bug.cs(3):: `Test.Generic<T>', name of symbol related to previous error
+generic-bug.cs(3):: `Test.Generic<T>', name of symbol related to previous error
+Compilation failed: 1 error(s), 0 warnings
+
+Visual Studio 2005 accepts the code, and of course Test.Generic<int> does
+have a public parameterless constructor.


More information about the mono-bugs mailing list