Bug 324740 (MONO82066) - [GMCS] encodes where T: struct differently than csc
Summary: [GMCS] encodes where T: struct differently than csc
Status: RESOLVED DUPLICATE of bug 416110
Alias: MONO82066
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Martin Baulig
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-11 13:59 UTC by Atsushi Enomoto
Modified: 2008-09-19 15:13 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:43:43 UTC


---- Reported by atsushi@ximian.com 2007-07-11 06:59:55 MST ----

The example below says that T of Nullable<T> has no constraint, while it is
constrained to struct. (where T : struct, new())

--------
using System;
using System.Reflection;

public class Test
{
        public static void Main ()
        {
                Type t = typeof (int?).GetGenericTypeDefinition ();
                Type n = t.GetGenericArguments () [0];
                Console.WriteLine (n.GetGenericParameterConstraints ().Length);
        }
}
--------

According to .NET ildasm, T in our mscorlib Nullable<T> is constrained, so
it's just that Type.GetGenericParameterConstraints() returns nothing.

I believe it used to work fine before (around a year ago). And IIRC this
issue existed before IMT (r81715). (Just dug into this issue today.)

It is also shown as corcompare difference in mscorlib page.



---- Additional Comments From vargaz@gmail.com 2007-07-31 10:30:58 MST ----

This is a gmcs bug. In the following test case:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
using System;
using System.Reflection;

public class Nullable2<T> where T : struct {
}

public class Test
{
        public static void Main ()
        {
                Type t = typeof
(Nullable2<int>).GetGenericTypeDefinition ();
                Type n = t.GetGenericArguments () [0];
                Console.WriteLine (n.GetGenericParameterConstraints
().Length);
                Console.WriteLine (n.GetGenericParameterConstraints
()[0]);
        }
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

gmcs encodes the constraints as:
<valuetype T>
while csc encodes it as:
<valuetype .ctor ([mscorlib]System.ValueType) T>



Unknown operating system unknown. Setting to default OS "Other".

Comment 1 Marek Safar 2008-09-19 15:13:56 UTC

*** This bug has been marked as a duplicate of bug 416110 ***