Use mono_class_has_parent for a faster supertypes check instead of
following the parent pointers.
MonoError error;
gboolean found = FALSE;
MonoClass *klass;
- MonoClass *k;
g_assert (handle);
} else {
klass = mono_class_from_mono_type (type);
- /* Check that the field belongs to the class */
- for (k = klass; k; k = k->parent) {
- if (k == handle->parent) {
- found = TRUE;
- break;
- }
- }
+ found = klass == handle->parent || mono_class_has_parent (klass, handle->parent);
if (!found)
/* The managed code will throw the exception */