Skip to content

Commit

Permalink
Fix support for ldfld/stfld wrappers in gshared code. Fixes #12086.
Browse files Browse the repository at this point in the history
  • Loading branch information
vargaz committed May 8, 2013
1 parent f423923 commit 63e5a3b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mono/metadata/marshal.c
Expand Up @@ -5015,6 +5015,10 @@ mono_marshal_get_ldfld_wrapper (MonoType *type)
mono_mb_emit_byte (mb, CEE_LDIND_REF);
}
break;
case MONO_TYPE_VAR:
case MONO_TYPE_MVAR:
mono_mb_emit_op (mb, CEE_LDOBJ, klass);
break;
default:
g_warning ("type %x not implemented", type->type);
g_assert_not_reached ();
Expand Down Expand Up @@ -5337,6 +5341,8 @@ mono_marshal_get_stfld_wrapper (MonoType *type)
mono_mb_emit_op (mb, CEE_STOBJ, klass);
break;
case MONO_TYPE_GENERICINST:
case MONO_TYPE_VAR:
case MONO_TYPE_MVAR:
mono_mb_emit_op (mb, CEE_STOBJ, klass);
break;
default:
Expand Down
15 changes: 15 additions & 0 deletions mono/mini/generics.cs
Expand Up @@ -308,6 +308,16 @@ public class MRO : MarshalByRefObject {
public GenericClass<int> class_field;
}

public class MRO<T> : MarshalByRefObject {
public T gen_field;

public T stfld_ldfld (T t) {
var m = this;
m.gen_field = t;
return m.gen_field;
}
}

public static int test_0_ldfld_stfld_mro () {
MRO m = new MRO ();
GenericStruct<int> s = new GenericStruct<int> (5);
Expand All @@ -330,6 +340,11 @@ public class MRO : MarshalByRefObject {
if (m.class_field.t != 5)
return 4;

// gshared
var m2 = new MRO<string> ();
if (m2.stfld_ldfld ("A") != "A")
return 5;

return 0;
}

Expand Down

0 comments on commit 63e5a3b

Please sign in to comment.