Bug 324741 (MONO82067) - gmcs does not emit generic parameter constraints on structs
Summary: gmcs does not emit generic parameter constraints on structs
Status: RESOLVED DUPLICATE of bug 416110
Alias: MONO82067
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: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-11 14:29 UTC by Atsushi Enomoto
Modified: 2008-09-19 15:16 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 07:29:57 MST ----

Looks like gmcs or SRE does not emit generic parameter constraints. Here is
an example (which also contains test for https://bugzilla.novell.com/show_bug.cgi?id=MONO82064), 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@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@PC ~/tests/generic
$ ./get-arg.exe
Foo`1[T] T 1
System.Nullable`1[T] T 1

atsushi@PC ~/tests/generic
$ mono ./get-arg.exe
Foo`1[T] T 1
System.Nullable`1[T] T 0

atsushi@PC ~/tests/generic
$ gmcs get-arg.cs

atsushi@PC ~/tests/generic
$ ./get-arg.exe
Foo`1[T] T 0
System.Nullable`1[T] T 1

atsushi@PC ~/tests/generic
$ mono get-arg.exe
Foo`1[T] T 0
System.Nullable`1[T] T 0



---- Additional Comments From atsushi@ximian.com 2007-07-19 22:06:20 MST ----

It is a difference between ClassConstraint and EffectiveBaseClass in
Mono.CSharp.Constraints. Replacing former with latter in DefineType()
solves this individual issue, but causes some regressions.


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

Comment 2 Marek Safar 2008-09-19 15:16:16 UTC

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