[aot] Handle gsharedvt versions of delegate invoke wrappers correctly, there could...
authorZoltan Varga <vargaz@gmail.com>
Tue, 24 Nov 2015 23:42:44 +0000 (18:42 -0500)
committerZoltan Varga <vargaz@gmail.com>
Tue, 24 Nov 2015 23:42:57 +0000 (18:42 -0500)
mono/mini/aot-runtime.c
mono/mini/aot-tests.cs

index bb6d72f607a188a06bc2b50c7c1340c6952a8272..1ddba2e998802aeb766f607d4c3743fde16b54a6 100644 (file)
@@ -1122,9 +1122,17 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod
                                        g_assert_not_reached ();
                                        break;
                                }
-                               if (target && wrapper != target)
-                                       return FALSE;
-                               ref->method = wrapper;
+                               if (target) {
+                                       /*
+                                        * Due to the way mini_get_shared_method () works, we could end up with
+                                        * multiple copies of the same wrapper.
+                                        */
+                                       if (wrapper->klass != target->klass)
+                                               return FALSE;
+                                       ref->method = target;
+                               } else {
+                                       ref->method = wrapper;
+                               }
                        } else {
                                /*
                                 * These wrappers are associated with a signature, not with a method.
index 048ae081e4e8ef7d3d54de059a5526ddad5d5551..1656da48e349c065e8b3e18305e5048c996f8c02 100644 (file)
@@ -312,4 +312,15 @@ class Tests
                        return 1;
                return 0;
        }
+
+       public static void SetArrayValue_<T> (T[] values) {
+               values.Select (x => x).ToArray ();
+       }
+
+       public static int test_0_delegate_invoke_wrappers_gsharedvt () {
+               var enums = new LongEnum [] { LongEnum.A };
+               SetArrayValue_ (enums);
+               return 0;
+       }
+
 }