2008-12-19 Mark Probst <mark.probst@gmail.com>
authorMark Probst <mark.probst@gmail.com>
Fri, 19 Dec 2008 10:39:22 +0000 (10:39 -0000)
committerMark Probst <mark.probst@gmail.com>
Fri, 19 Dec 2008 10:39:22 +0000 (10:39 -0000)
        Backport of r121292.

        * method-to-ir.c: Removed an unnecessary assertion.

2008-12-19  Mark Probst  <mark.probst@gmail.com>

        Backport of r121292.

        * metadata/generic-sharing.c: Look for constraints in all type
        arguments, not just the first one.

2008-12-19  Mark Probst  <mark.probst@gmail.com>

        Backport of r121292.

        * generic-marshalbyref.2.cs: Test for calls to marshal-by-ref
        objects.

        * Makefile.am: Test added.

svn path=/branches/mono-2-2/mono/; revision=121836

mono/metadata/ChangeLog
mono/metadata/generic-sharing.c
mono/mini/ChangeLog
mono/mini/method-to-ir.c
mono/tests/ChangeLog
mono/tests/Makefile.am
mono/tests/generic-marshalbyref.2.cs [new file with mode: 0644]

index c1e0d900b743b122e7f1ccae60c8c59998407ef5..e4cccbcef8142d0a8dacbc71f0a0ada7b6df0368 100644 (file)
@@ -1,3 +1,10 @@
+2008-12-19  Mark Probst  <mark.probst@gmail.com>
+
+       Backport of r121292.
+
+       * metadata/generic-sharing.c: Look for constraints in all type
+       arguments, not just the first one.
+
 2008-12-17  Geoff Norton  <gnorton@novell.com>
 
        * threadpool.c: Ensure that the io_queue_lock is initialized
index 42361d2cb8115c20e0d5c893a1142c572ede8b25..a341c64af55607c97cbbf8a7f9c3bdea82d32c9d 100644 (file)
@@ -1347,6 +1347,20 @@ mono_method_is_generic_impl (MonoMethod *method)
        return FALSE;
 }
 
+static gboolean
+has_constraints (MonoGenericContainer *container)
+{
+       int i;
+
+       g_assert (container->type_argc > 0);
+       g_assert (container->type_params);
+
+       for (i = 0; i < container->type_argc; ++i)
+               if (container->type_params [i].constraints)
+                       return TRUE;
+       return FALSE;
+}
+
 /*
  * mono_method_is_generic_sharable_impl:
  * @method: a method
@@ -1372,9 +1386,7 @@ mono_method_is_generic_sharable_impl (MonoMethod *method, gboolean allow_type_va
                g_assert (inflated->declaring);
 
                if (inflated->declaring->is_generic) {
-                       g_assert (mono_method_get_generic_container (inflated->declaring)->type_params);
-
-                       if (mono_method_get_generic_container (inflated->declaring)->type_params->constraints)
+                       if (has_constraints (mono_method_get_generic_container (inflated->declaring)))
                                return FALSE;
                }
        }
@@ -1384,10 +1396,9 @@ mono_method_is_generic_sharable_impl (MonoMethod *method, gboolean allow_type_va
                        return FALSE;
 
                g_assert (method->klass->generic_class->container_class &&
-                               method->klass->generic_class->container_class->generic_container &&
-                               method->klass->generic_class->container_class->generic_container->type_params);
+                               method->klass->generic_class->container_class->generic_container);
 
-               if (method->klass->generic_class->container_class->generic_container->type_params->constraints)
+               if (has_constraints (method->klass->generic_class->container_class->generic_container))
                        return FALSE;
        }
 
index 86961528e971ac39f2ea5c3ff3d92482b61bff15..cd0ac1e59de7ebaa222fa1e97096c1ed69f33aab 100644 (file)
@@ -1,3 +1,9 @@
+2008-12-19  Mark Probst  <mark.probst@gmail.com>
+
+       Backport of r121292.
+
+       * method-to-ir.c: Removed an unnecessary assertion.
+
 2008-12-16  Martin Baulig  <martin@ximian.com>
 
        Backport of r120438.
index 4a4205f84c25a7336bf7df06f75496594f958917..f7bd0a609b0abd69d55f5c16d716683a615c6659 100644 (file)
@@ -7305,8 +7305,6 @@ mono_method_to_ir2 (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_
                                                        !mono_class_generic_sharing_enabled (cmethod->klass))) {
                                        MonoInst *cmethod_addr;
 
-                                       g_assert (!callvirt_this_arg);
-
                                        cmethod_addr = emit_get_rgctx_method (cfg, context_used,
                                                cmethod, MONO_RGCTX_INFO_GENERIC_METHOD_CODE);
 
index a8164070316a010073542bd250e2cff00a46d122..183c44d10d27c339ddc7632b13c00cc266f4b79f 100644 (file)
@@ -1,3 +1,12 @@
+2008-12-19  Mark Probst  <mark.probst@gmail.com>
+
+       Backport of r121292.
+
+       * generic-marshalbyref.2.cs: Test for calls to marshal-by-ref
+       objects.
+
+       * Makefile.am: Test added.
+
 2008-12-08  Rodrigo Kumpera  <rkumpera@novell.com>
 
        * bug457574.il: New regression test.
index b45b30ea8ee8bbb3e22c54586918d6160e756289..502165a9b10ebe3c4b7628d0db597f26c41cd010 100644 (file)
@@ -288,6 +288,7 @@ BASE_TEST_CS_SRC=           \
        generic-delegate-ctor.2.cs      \
        generic-array-iface-set.2.cs    \
        generic-typedef.2.cs    \
+       generic-marshalbyref.2.cs       \
        bug-431413.2.cs \
        generic-virtual-invoke.2.cs     \
        recursive-generics.2.cs \
@@ -717,7 +718,8 @@ test-generic-sharing : generics-sharing.2.exe shared-generic-methods.2.exe  \
                generic-getgenericarguments.2.exe generic-type-builder.2.exe    \
                generic-synchronized.2.exe generic-delegate-ctor.2.exe          \
                generic-constrained.2.exe bug-431413.2.exe                      \
-               generic-virtual-invoke.2.exe generic-typedef.2.exe
+               generic-virtual-invoke.2.exe generic-typedef.2.exe              \
+               generic-marshalbyref.2.exe
        @for fn in $+ ; do      \
                echo "Testing $$fn ...";        \
                MONO_GENERIC_SHARING=all $(RUNTIME) -O=gshared                $$fn > $$fn.stdout || exit 1;     \
diff --git a/mono/tests/generic-marshalbyref.2.cs b/mono/tests/generic-marshalbyref.2.cs
new file mode 100644 (file)
index 0000000..1576b37
--- /dev/null
@@ -0,0 +1,39 @@
+using System;
+
+static class Program
+{
+    static int Main()
+    {
+           DocumentForm<object> browseForm = new DocumentForm<object> ();
+           if (browseForm.DoInit () != 124)
+                   return 1;
+           return 0;
+    }
+}
+
+public abstract class EntityBase
+{
+}
+
+public class GenEntity<T> : EntityBase
+{
+}
+
+class DocumentForm<T>
+{
+       internal int DoInit()
+       {
+               var g = new Grid1<GenEntity<T>>(123);
+               return g.num;
+       }
+}
+
+public class Grid1<TEntity> : MarshalByRefObject where TEntity : EntityBase, new()
+{
+       public int num;
+
+       public Grid1 (int i)
+       {
+               num = i + 1;
+       }
+}