@@ -2281,12 +2281,20 @@ emit_struct_conv_full (MonoMethodBuilder *mb, MonoClass *klass, gboolean to_obje
2281
2281
mono_mb_emit_byte (mb , mono_type_to_stind (ftype ));
2282
2282
}
2283
2283
break ;
2284
+ case MONO_TYPE_GENERICINST :
2285
+ if (!mono_type_generic_inst_is_valuetype (ftype )) {
2286
+ char * msg = g_strdup_printf ("Generic type %s cannot be marshaled as field in a struct." ,
2287
+ mono_type_full_name (ftype ));
2288
+ mono_mb_emit_exception_marshal_directive (mb , msg );
2289
+ break ;
2290
+ }
2291
+ /* fall through */
2284
2292
case MONO_TYPE_VALUETYPE : {
2285
2293
int src_var , dst_var ;
2286
2294
MonoType * etype ;
2287
2295
int len ;
2288
2296
2289
- if (ftype -> data .klass -> enumtype ) {
2297
+ if (t == MONO_TYPE_VALUETYPE && ftype -> data .klass -> enumtype ) {
2290
2298
ftype = mono_class_enum_basetype (ftype -> data .klass );
2291
2299
goto handle_enum ;
2292
2300
}
@@ -2304,7 +2312,7 @@ emit_struct_conv_full (MonoMethodBuilder *mb, MonoClass *klass, gboolean to_obje
2304
2312
if (get_fixed_buffer_attr (info -> fields [i ].field , & etype , & len )) {
2305
2313
emit_fixed_buf_conv (mb , ftype , etype , len , to_object , & usize );
2306
2314
} else {
2307
- emit_struct_conv (mb , ftype -> data . klass , to_object );
2315
+ emit_struct_conv (mb , mono_class_from_mono_type ( ftype ) , to_object );
2308
2316
}
2309
2317
2310
2318
/* restore the old src pointer */
0 commit comments