2008-05-21 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Wed, 21 May 2008 21:25:38 +0000 (21:25 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Wed, 21 May 2008 21:25:38 +0000 (21:25 -0000)
* loader.c (mono_get_method_constrained): Inflate the signature
with class context. Fix #325283.

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

mono/metadata/ChangeLog
mono/metadata/loader.c

index 387998c54d60e9d40aa37135d5723810062257b6..dec7e0fe7a9ba987113c5b4e6fd815547ba02fba 100644 (file)
@@ -1,3 +1,8 @@
+2008-05-21 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * loader.c (mono_get_method_constrained): Inflate the signature
+       with class context. Fix #325283.
+
 2008-05-21  Zoltan Varga  <vargaz@gmail.com>
 
        * object.c (mono_class_create_runtime_vtable): Add a comment.
index 5302095ba25346a51bbf1ff73b85e104651bc774..64c1439546f97c0875ee0baab0521ba93513ce60 100644 (file)
@@ -1485,7 +1485,7 @@ mono_get_method_constrained (MonoImage *image, guint32 token, MonoClass *constra
        MonoMethod *method, *result;
        MonoClass *ic = NULL;
        MonoGenericContext *class_context = NULL, *method_context = NULL;
-       MonoMethodSignature *sig;
+       MonoMethodSignature *sig, *original_sig;
 
        mono_loader_lock ();
 
@@ -1497,12 +1497,26 @@ mono_get_method_constrained (MonoImage *image, guint32 token, MonoClass *constra
 
        mono_class_init (constrained_class);
        method = *cil_method;
-       sig = mono_method_signature (method);
+       original_sig = sig = mono_method_signature (method);
 
        if (method->is_inflated && sig->generic_param_count) {
                MonoMethodInflated *imethod = (MonoMethodInflated *) method;
                sig = mono_method_signature (imethod->declaring);
                method_context = mono_method_get_context (method);
+
+               original_sig = sig;
+               /*
+                * We must inflate the signature with the class instantiation to work on
+                * cases where a class inherit from a generic type and the override replaces
+                * and type argument which a concrete type. See #325283.
+                */
+               if (method_context->class_inst) {
+                       MonoGenericContext ctx;
+                       ctx.method_inst = NULL;
+                       ctx.class_inst = method_context->class_inst;
+               
+                       sig = inflate_generic_signature (method->klass->image, sig, &ctx);
+               }
        }
 
        if ((constrained_class != method->klass) && (method->klass->interface_id != 0))
@@ -1512,6 +1526,9 @@ mono_get_method_constrained (MonoImage *image, guint32 token, MonoClass *constra
                class_context = mono_class_get_context (constrained_class);
 
        result = find_method (constrained_class, ic, method->name, sig, constrained_class);
+       if (sig != original_sig)
+               mono_metadata_free_inflated_signature (sig);
+
        if (!result) {
                g_warning ("Missing method %s.%s.%s in assembly %s token %x", method->klass->name_space,
                           method->klass->name, method->name, image->name, token);