@@ -2266,7 +2266,7 @@ emit_array_accessor_wrapper_ilgen (MonoMethodBuilder *mb, MonoMethod *method, Mo
22662266}
22672267
22682268static void
2269- emit_unsafe_accessor_field_wrapper (MonoMethodBuilder * mb ,MonoMethod * accessor_method ,MonoMethodSignature * sig ,MonoGenericContext * ctx , MonoUnsafeAccessorKind kind ,const char * member_name )
2269+ emit_unsafe_accessor_field_wrapper (MonoMethodBuilder * mb ,MonoMethod * accessor_method ,MonoMethodSignature * sig ,MonoUnsafeAccessorKind kind ,const char * member_name )
22702270{
22712271// Field access requires a single argument for target type and a return type.
22722272g_assert (kind == MONO_UNSAFE_ACCESSOR_FIELD || kind == MONO_UNSAFE_ACCESSOR_STATIC_FIELD );
@@ -2315,7 +2315,7 @@ emit_unsafe_accessor_field_wrapper (MonoMethodBuilder *mb, MonoMethod *accessor_
23152315 * of the expected member method (ie, with the first arg removed)
23162316 */
23172317static MonoMethodSignature *
2318- method_sig_from_accessor_sig (MonoMethodBuilder * mb ,gboolean hasthis ,MonoMethodSignature * accessor_sig , MonoGenericContext * ctx )
2318+ method_sig_from_accessor_sig (MonoMethodBuilder * mb ,gboolean hasthis ,MonoMethodSignature * accessor_sig )
23192319{
23202320MonoMethodSignature * ret = mono_metadata_signature_dup_full (get_method_image (mb -> method ),accessor_sig );
23212321g_assert (ret -> param_count > 0 );
@@ -2332,7 +2332,7 @@ method_sig_from_accessor_sig (MonoMethodBuilder *mb, gboolean hasthis, MonoMetho
23322332 * of the expected constructor method (same args, but return type is void).
23332333 */
23342334static MonoMethodSignature *
2335- ctor_sig_from_accessor_sig (MonoMethodBuilder * mb ,MonoMethodSignature * accessor_sig , MonoGenericContext * ctx )
2335+ ctor_sig_from_accessor_sig (MonoMethodBuilder * mb ,MonoMethodSignature * accessor_sig )
23362336{
23372337MonoMethodSignature * ret = mono_metadata_signature_dup_full (get_method_image (mb -> method ),accessor_sig );
23382338ret -> hasthis = TRUE;/* ctors are considered instance methods */
@@ -2410,7 +2410,7 @@ inflate_method (MonoClass *klass, MonoMethod *method, MonoMethod *accessor_metho
24102410}
24112411
24122412static void
2413- emit_unsafe_accessor_ctor_wrapper (MonoMethodBuilder * mb ,MonoMethod * accessor_method ,MonoMethodSignature * sig ,MonoGenericContext * ctx , MonoUnsafeAccessorKind kind ,const char * member_name )
2413+ emit_unsafe_accessor_ctor_wrapper (MonoMethodBuilder * mb ,MonoMethod * accessor_method ,MonoMethodSignature * sig ,MonoUnsafeAccessorKind kind ,const char * member_name )
24142414{
24152415g_assert (kind == MONO_UNSAFE_ACCESSOR_CTOR );
24162416// null or empty string member name is ok for a constructor
@@ -2434,7 +2434,7 @@ emit_unsafe_accessor_ctor_wrapper (MonoMethodBuilder *mb, MonoMethod *accessor_m
24342434sig = update_signature (accessor_method );
24352435}
24362436
2437- MonoMethodSignature * member_sig = ctor_sig_from_accessor_sig (mb ,sig , ctx );
2437+ MonoMethodSignature * member_sig = ctor_sig_from_accessor_sig (mb ,sig );
24382438
24392439MonoClass * in_class = mono_class_get_generic_type_definition (target_class );
24402440
@@ -2459,7 +2459,7 @@ emit_unsafe_accessor_ctor_wrapper (MonoMethodBuilder *mb, MonoMethod *accessor_m
24592459}
24602460
24612461static void
2462- emit_unsafe_accessor_method_wrapper (MonoMethodBuilder * mb ,MonoMethod * accessor_method ,MonoMethodSignature * sig ,MonoGenericContext * ctx , MonoUnsafeAccessorKind kind ,const char * member_name )
2462+ emit_unsafe_accessor_method_wrapper (MonoMethodBuilder * mb ,MonoMethod * accessor_method ,MonoMethodSignature * sig ,MonoUnsafeAccessorKind kind ,const char * member_name )
24632463{
24642464g_assert (kind == MONO_UNSAFE_ACCESSOR_METHOD || kind == MONO_UNSAFE_ACCESSOR_STATIC_METHOD );
24652465g_assert (member_name != NULL );
@@ -2486,7 +2486,7 @@ emit_unsafe_accessor_method_wrapper (MonoMethodBuilder *mb, MonoMethod *accessor
24862486sig = update_signature (accessor_method );
24872487}
24882488
2489- MonoMethodSignature * member_sig = method_sig_from_accessor_sig (mb ,hasthis ,sig , ctx );
2489+ MonoMethodSignature * member_sig = method_sig_from_accessor_sig (mb ,hasthis ,sig );
24902490
24912491MonoClass * in_class = mono_class_get_generic_type_definition (target_class );
24922492
@@ -2520,9 +2520,14 @@ emit_unsafe_accessor_method_wrapper (MonoMethodBuilder *mb, MonoMethod *accessor
25202520}
25212521
25222522static void
2523- emit_unsafe_accessor_wrapper_ilgen (MonoMethodBuilder * mb ,MonoMethod * accessor_method ,MonoMethodSignature * sig ,MonoGenericContext * ctx ,MonoUnsafeAccessorKind kind ,const char * member_name )
2523+ emit_unsafe_accessor_wrapper_ilgen (MonoMethodBuilder * mb ,MonoMethod * accessor_method ,MonoMethodSignature * sig ,gboolean to_be_inflated ,MonoUnsafeAccessorKind kind ,const char * member_name )
25242524{
2525- if (accessor_method -> is_generic || ctx != NULL ) {
2525+ // to_be_inflated means we're emitting a non-generic accessor method belonging to a gtd
2526+ // that will be inflated by marshal.c
2527+ if (to_be_inflated )
2528+ g_assert (!accessor_method -> is_inflated && !accessor_method -> is_generic );
2529+
2530+ if (accessor_method -> is_generic || to_be_inflated ) {
25262531mono_mb_emit_exception_full (mb ,"System" ,"BadImageFormatException" ,"UnsafeAccessor_Generics" );
25272532return ;
25282533}
@@ -2535,14 +2540,14 @@ emit_unsafe_accessor_wrapper_ilgen (MonoMethodBuilder *mb, MonoMethod *accessor_
25352540switch (kind ) {
25362541case MONO_UNSAFE_ACCESSOR_FIELD :
25372542case MONO_UNSAFE_ACCESSOR_STATIC_FIELD :
2538- emit_unsafe_accessor_field_wrapper (mb ,accessor_method ,sig ,ctx , kind ,member_name );
2543+ emit_unsafe_accessor_field_wrapper (mb ,accessor_method ,sig ,kind ,member_name );
25392544return ;
25402545case MONO_UNSAFE_ACCESSOR_CTOR :
2541- emit_unsafe_accessor_ctor_wrapper (mb ,accessor_method ,sig ,ctx , kind ,member_name );
2546+ emit_unsafe_accessor_ctor_wrapper (mb ,accessor_method ,sig ,kind ,member_name );
25422547return ;
25432548case MONO_UNSAFE_ACCESSOR_METHOD :
25442549case MONO_UNSAFE_ACCESSOR_STATIC_METHOD :
2545- emit_unsafe_accessor_method_wrapper (mb ,accessor_method ,sig ,ctx , kind ,member_name );
2550+ emit_unsafe_accessor_method_wrapper (mb ,accessor_method ,sig ,kind ,member_name );
25462551return ;
25472552default :
25482553mono_mb_emit_exception_full (mb ,"System" ,"BadImageFormatException" ,"UnsafeAccessor_InvalidKindValue" );