When encoding a memberref to a field of a generic instance we must use the type of...
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 7 Feb 2013 23:55:47 +0000 (18:55 -0500)
committerRodrigo Kumpera <kumpera@gmail.com>
Fri, 8 Feb 2013 00:22:14 +0000 (19:22 -0500)
commitfc3c31dcc33e38ca48d546982c74be90aa608821
tree64aef8191010bc256c160e0deda21558e84133fa
parent78318771d52403e6b0588eb04dd8f74afa7f43f8
When encoding a memberref to a field of a generic instance we must use the type of the GTD. Fixes #10122

* reflection.c (mono_image_get_fieldref_token): We must encode the memberref using the GTD type so
we can distinguish between the following two:

class Foo<T> {
T t;
int t;
}

The above two fields for the instance Foo<int> must be encoded as "!0 Foo<int>:t" and "int Foo<int>:t"
respectively. The CLR does both structural and nominal matching on memberref resolution, so we must be
strict.

The previous fix removed tried to work-around a crash in the generic instance case due to the field
type been null. This now happens because field types are lazily loaded and must always be looked up
using mono_field_get_type. The original code code was not and so broken.
mono/metadata/reflection.c