[runtime] Change mono_type_get_full to use mono_class_get_checked.
authorRodrigo Kumpera <kumpera@gmail.com>
Fri, 29 Aug 2014 00:30:17 +0000 (20:30 -0400)
committerRodrigo Kumpera <kumpera@gmail.com>
Tue, 9 Sep 2014 20:34:52 +0000 (16:34 -0400)
mono/metadata/class.c

index 53760778c484d4ef236e286b6d4affe74ed7ccea..c9cdaf1df37814ec68f3c5a133cace22929c1f39 100644 (file)
@@ -7212,21 +7212,30 @@ mono_type_get_full (MonoImage *image, guint32 type_token, MonoGenericContext *co
                return mono_class_get_type (mono_lookup_dynamic_token (image, type_token, context));
 
        if ((type_token & 0xff000000) != MONO_TOKEN_TYPE_SPEC) {
-               MonoClass *class = mono_class_get_full (image, type_token, context);
-               return class ? mono_class_get_type (class) : NULL;
+               MonoClass *class = mono_class_get_checked (image, type_token, &error);
+
+               if (!mono_error_ok (&error)) {
+                       mono_loader_set_error_from_mono_error (&error);
+                       /*FIXME don't swallow the error message*/
+                       mono_error_cleanup (&error);
+                       return NULL;
+               }
+
+               g_assert (class);
+               return mono_class_get_type (class);
        }
 
        type = mono_type_retrieve_from_typespec (image, type_token, context, &inflated, &error);
 
        if (!mono_error_ok (&error)) {
-               /*FIXME don't swalloc the error message.*/
                char *name = mono_class_name_from_token (image, type_token);
                char *assembly = mono_assembly_name_from_token (image, type_token);
 
                g_warning ("Error loading type %s from %s due to %s", name, assembly, mono_error_get_message (&error));
 
-               mono_error_cleanup (&error);
                mono_loader_set_error_type_load (name, assembly);
+               /*FIXME don't swallow the error message.*/
+               mono_error_cleanup (&error);
                return NULL;
        }