[Mono-bugs] [Bug 82067][Nor] New - gmcs does not emit generic parameter constraints on structs

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Jul 11 07:29:57 EDT 2007


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 atsushi at ximian.com.

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

--- shadow/82067	2007-07-11 07:29:57.000000000 -0400
+++ shadow/82067.tmp.13438	2007-07-11 07:29:57.000000000 -0400
@@ -0,0 +1,77 @@
+Bug#: 82067
+Product: Mono: Compilers
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: atsushi at ximian.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: gmcs does not emit generic parameter constraints on structs
+
+Looks like gmcs or SRE does not emit generic parameter constraints. Here is
+an example (which also contains test for bug #82064), ran on cygwin (note
+that #82064 is for runtime).
+
+$ cat get-arg.cs
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+
+public struct Foo<T> where T : struct
+{
+}
+
+public class Test
+{
+        public static void Main ()
+        {
+                DoTest (typeof (Foo<int>));
+                DoTest (typeof (int?));
+        }
+
+        static void DoTest (Type type)
+        {
+                Type t = type.GetGenericTypeDefinition ();
+                Type n = t.GetGenericArguments () [0];
+                Console.WriteLine ("{0} {1} {2}",
+                        t, n, n.GetGenericParameterConstraints ().Length);
+        }
+}
+
+atsushi at PC ~/tests/generic
+$ csc get-arg.cs
+Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.1318
+for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
+Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.
+
+
+atsushi at PC ~/tests/generic
+$ ./get-arg.exe
+Foo`1[T] T 1
+System.Nullable`1[T] T 1
+
+atsushi at PC ~/tests/generic
+$ mono ./get-arg.exe
+Foo`1[T] T 1
+System.Nullable`1[T] T 0
+
+atsushi at PC ~/tests/generic
+$ gmcs get-arg.cs
+
+atsushi at PC ~/tests/generic
+$ ./get-arg.exe
+Foo`1[T] T 0
+System.Nullable`1[T] T 1
+
+atsushi at PC ~/tests/generic
+$ mono get-arg.exe
+Foo`1[T] T 0
+System.Nullable`1[T] T 0


More information about the mono-bugs mailing list