- if (mono_class_is_assignable_from (mono_class_inflate_generic_class (icomparable, &ctx), tclass)) {
- gcomparer = mono_class_from_name (mono_defaults.corlib, "System.Collections.Generic", "GenericComparer`1");
- g_assert (gcomparer);
- add_generic_class (acfg, mono_class_inflate_generic_class (gcomparer, &ctx), FALSE, "Comparer<T>");
+ icomparable_inst = mono_class_inflate_generic_class_checked (icomparable, &ctx, &error);
+ mono_error_assert_ok (&error); /* FIXME don't swallow the error */
+
+ if (mono_class_is_assignable_from (icomparable_inst, tclass)) {
+ MonoClass *gcomparer_inst;
+ gcomparer = mono_class_load_from_name (mono_defaults.corlib, "System.Collections.Generic", "GenericComparer`1");
+ gcomparer_inst = mono_class_inflate_generic_class_checked (gcomparer, &ctx, &error);
+ mono_error_assert_ok (&error); /* FIXME don't swallow the error */
+
+ add_generic_class (acfg, gcomparer_inst, FALSE, "Comparer<T>");