[633277] Import type parameters used as type parameter constraints
authorMarek Safar <marek.safar@gmail.com>
Tue, 24 Aug 2010 09:57:55 +0000 (10:57 +0100)
committerMarek Safar <marek.safar@gmail.com>
Tue, 24 Aug 2010 09:59:20 +0000 (10:59 +0100)
mcs/mcs/import.cs
mcs/tests/gtest-532-lib.cs [new file with mode: 0644]
mcs/tests/gtest-532.cs [new file with mode: 0644]

index 1706891958b60186251b68f4c4e8d86c235523c7..1c39f4245046edc7ccdb37ae6ee5ff77d49ab446 100644 (file)
@@ -221,10 +221,6 @@ namespace Mono.CSharp
                public static MethodSpec CreateMethod (MethodBase mb, TypeSpec declaringType)
                {
                        Modifiers mod = ReadMethodModifiers (mb, declaringType);
-                       //if (declaringType.IsInterface) {
-                       //    mod = (mod & ~Modifiers.ABSTRACT) | Modifiers.VIRTUAL;
-                       //}
-
                        TypeParameterSpec[] tparams;
                        ImportedMethodDefinition definition;
 
@@ -605,9 +601,13 @@ namespace Mono.CSharp
                        import_cache.Add (type, spec);
 
                        var constraints = type.GetGenericParameterConstraints ();
+                       List<TypeSpec> tparams = null;
                        foreach (var ct in constraints) {
-                               // TODO MemberCache: What to do ??
                                if (ct.IsGenericParameter) {
+                                       if (tparams == null)
+                                               tparams = new List<TypeSpec> ();
+
+                                       tparams.Add (CreateType (ct));
                                        continue;
                                }
 
@@ -627,6 +627,9 @@ namespace Mono.CSharp
                        if (spec.BaseType == null)
                                spec.BaseType = TypeManager.object_type;
 
+                       if (tparams != null)
+                               spec.TypeArguments = tparams.ToArray ();
+
                        return spec;
                }
 
diff --git a/mcs/tests/gtest-532-lib.cs b/mcs/tests/gtest-532-lib.cs
new file mode 100644 (file)
index 0000000..2f3db35
--- /dev/null
@@ -0,0 +1,7 @@
+// Compiler options: -t:library
+
+public interface IServicesContainer
+{
+       void Register<I, T> () where T : I;
+       void Register<I> (object instance);
+}
diff --git a/mcs/tests/gtest-532.cs b/mcs/tests/gtest-532.cs
new file mode 100644 (file)
index 0000000..c42cc45
--- /dev/null
@@ -0,0 +1,26 @@
+// Compiler options: -r:gtest-532-lib.dll
+
+using System;
+
+public class DictionaryServicesContainer : IServicesContainer
+{
+       public void Register<I, T> () where T : I
+       {
+               throw new NotImplementedException ();
+       }
+
+       public void Register<I> (object instance)
+       {
+               throw new NotImplementedException ();
+       }
+
+       public I Resolve<I> ()
+       {
+               throw new NotImplementedException ();
+       }
+
+       public static void Main ()
+       {
+               new DictionaryServicesContainer ();
+       }
+}