2008-12-11 Mark Probst <mark.probst@gmail.com>
authorMark Probst <mark.probst@gmail.com>
Thu, 11 Dec 2008 14:55:41 +0000 (14:55 -0000)
committerMark Probst <mark.probst@gmail.com>
Thu, 11 Dec 2008 14:55:41 +0000 (14:55 -0000)
* metadata/generic-sharing.c: Look for constraints in all type
arguments, not just the first one.

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

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

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

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

* Makefile.am: Test added.

svn path=/trunk/mono/; revision=121292

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 758080d0ded4830763c55a3f6a0f4cd2310a4ac6..d30836a883e5d9db8adc8bd54baa0f8737af36af 100644 (file)
@@ -1,3 +1,7 @@
+2008-12-11  Mark Probst  <mark.probst@gmail.com>
+
+       * metadata/generic-sharing.c: Look for constraints in all type
+       arguments, not just the first one.
 
 2008-12-10 Gonzalo Paniagua Javier <gonzalo@novell.com>
 
index ee0660f59be2e7adda2271c2684f884c096fd7bb..88b81ea3bfcd8262b72291932f6b722c9a597260 100644 (file)
@@ -1348,6 +1348,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
@@ -1373,9 +1387,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;
                }
        }
@@ -1385,10 +1397,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 c4773221f1714b07d428513f57f3cdc766fbed9d..05114a8f155fa932ab3e49774f969ecd3864e5cc 100644 (file)
@@ -1,3 +1,7 @@
+2008-12-11  Mark Probst  <mark.probst@gmail.com>
+
+       * method-to-ir.c: Removed an unnecessary assertion.
+
 2008-12-10  Zoltan Varga  <vargaz@gmail.com>
 
        * method-to-ir.c: Merge SGEN changes from the old JIT.
index 61ca22e903dabe036d1ff8d6cc4e5a1a92df75f6..a2ff0742b03e05466d76d11db44a485febcc95a3 100644 (file)
@@ -7316,8 +7316,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                                        !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 20bb75898b21ffa8aec8abd271b427e31b11c2a8..26f57f0a8425d445110e449feef2f12c60d8b771 100644 (file)
@@ -1,3 +1,10 @@
+2008-12-11  Mark Probst  <mark.probst@gmail.com>
+
+       * generic-marshalbyref.2.cs: Test for calls to marshal-by-ref
+       objects.
+
+       * Makefile.am: Test added.
+
 2008-12-08  Rodrigo Kumpera  <rkumpera@novell.com>
 
        * bug445361.il: New regression test.
index 72603205a96ddf1b81146385eb6636da3bc608d1..f54ee3c2e3578720071b10c1212b714ca9c84a39 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 \
@@ -720,7 +721,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;
+       }
+}