[Mono-dev] Generic Variance

Rodrigo Kumpera kumpera at gmail.com
Mon Feb 9 13:36:47 EST 2009


@@ -5875,9 +5921,10 @@

     container = klass->generic_class->container_class->generic_container;

-    for (i = 0; i < container->type_argc; ++i)
-        if (container->type_params [i].flags &
(MONO_GEN_PARAM_VARIANT|MONO_GEN_PARAM_COVARIANT))
+    for (i = 0; i < container->type_argc; ++i) {
+        if (container->type_params [i].flags &
GENERIC_PARAMETER_ATTRIBUTE_VARIANCE_MASK)
             return TRUE;
+    }

     return FALSE;
 }

This change is not necessary.

@@ -5919,55 +5966,23 @@
         if (MONO_CLASS_IMPLEMENTS_INTERFACE (oklass, klass->interface_id))
             return TRUE;

-        if (mono_class_has_variant_generic_params (klass)) {
-            if (oklass->generic_class) {
-                int i;
-                gboolean match = FALSE;
-                MonoClass *container_class1 =
klass->generic_class->container_class;
-                MonoClass *container_class2 =
oklass->generic_class->container_class;
+        if (mono_class_has_variant_generic_params (klass) &&
oklass->generic_class) {
+            int i;
+            gboolean match = FALSE;
+            MonoClass *container_class1 =
klass->generic_class->container_class;
+            MonoClass *container_class2 =
oklass->generic_class->container_class;


Please only change the innerloop that was extracted to
mono_class_is_variant_of. Don't change the
nested if as it introduces a huge change bloat for no gain. Leave cleanups
for a separate patch.


@@ -198,6 +198,9 @@
 MonoClass*
 mono_class_get_nested_types  (MonoClass* klass, gpointer *iter);

+int
+mono_class_interface_offset_with_variance (MonoClass *klass, MonoClass
*itf);
+

This must be flagged MONO_INTERNAL


+2009-02-07  Scott Peterson  <lunchtimemama at gmail.com>
+
+    Contrubuted under the MIT/X11 license.

Small typo ;)

Index: mono/mini/Makefile.am
===================================================================
--- mono/mini/Makefile.am    (revision 126150)
+++ mono/mini/Makefile.am    (working copy)
@@ -283,6 +283,7 @@
     test.cs            \
     generics.cs        \
     generics-variant-types.il\
+    generics-variant-types.cs\
     basic-simd.cs

Please rebase your patch as generics-variant-types.il isn't part of
Makefile.am


Thanks,
Rodrigo

On Sat, Feb 7, 2009 at 12:58 AM, Scott Peterson <lunchtimemama at gmail.com>wrote:

> And this adds more test logic (and fixes the tests that was already there).
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090209/af5c0976/attachment.html 


More information about the Mono-devel-list mailing list