Skip to content

Commit a6e38b3

Browse files
Josh PetersonSaiprasad945
authored andcommitted
Avoid throwing TypeLoadException for generic 2D arrays (case UUM-34854)
Mono was a bit too aggressive with its TypeLoadException processing, not allowing some valid code in this case. This change applies the fix from: dotnet/runtime#85828
1 parent 9951927 commit a6e38b3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mono/metadata/class-init.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,8 +1124,10 @@ mono_class_create_bounded_array (MonoClass *eclass, guint32 rank, gboolean bound
11241124

11251125
mono_class_setup_supertypes (klass);
11261126

1127-
if (mono_class_is_ginst (eclass))
1128-
mono_class_init_internal (eclass);
1127+
// NOTE: this is probably too aggressive if eclass is not a valuetype. It looks like we
1128+
// only need the size info in order to set MonoClass:has_references for this array type -
1129+
// and for that we only need to setup the fields of the element type if it's not a reference
1130+
// type.
11291131
if (!eclass->size_inited)
11301132
mono_class_setup_fields (eclass);
11311133
mono_class_set_type_load_failure_causedby_class (klass, eclass, "Could not load array element type");

0 commit comments

Comments
 (0)