Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff5fdab

Browse files
authored
[mono][metadata] Defer class init for T when initializing T[]. (#115278)
1 parent 5ccaddf commit ff5fdab

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/mono/mono/metadata/class-init.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -1198,16 +1198,19 @@ mono_class_create_bounded_array (MonoClass *eclass, guint32 rank, gboolean bound
11981198

11991199
mono_class_setup_supertypes (klass);
12001200

1201-
// NOTE: this is probably too aggressive if eclass is not a valuetype. It looks like we
1202-
// only need the size info in order to set MonoClass:has_references for this array type -
1203-
// and for that we only need to setup the fields of the element type if it's not a reference
1204-
// type.
1205-
if (!eclass->size_inited)
1201+
// It looks like we only need the size info in order to set MonoClass:has_references
1202+
// for this array type and for that we only need to setup the fields of the element
1203+
// type if it's not a reference type.
1204+
gboolean is_eclass_valuetype = m_class_is_valuetype (eclass);
1205+
if (is_eclass_valuetype && !eclass->size_inited)
12061206
mono_class_setup_fields (eclass);
12071207
mono_class_set_type_load_failure_causedby_class (klass, eclass, "Could not load array element type");
12081208
/*FIXME we fail the array type, but we have to let other fields be set.*/
12091209

1210-
klass->has_references = MONO_TYPE_IS_REFERENCE (m_class_get_byval_arg (eclass)) || m_class_has_references (eclass)? TRUE: FALSE;
1210+
if (is_eclass_valuetype)
1211+
klass->has_references = m_class_has_references (eclass) ? TRUE : FALSE;
1212+
else
1213+
klass->has_references = TRUE;
12111214

12121215
if (eclass->enumtype)
12131216
klass->cast_class = eclass->element_class;

0 commit comments

Comments
 (0)