[sre] Emit a memberref token for fields,methods of a gtd
commit009e2d8835bfa19913ecc56116bb744991a4af85
authorAleksey Kliger <alklig@microsoft.com>
Sat, 9 Dec 2017 00:02:07 +0000 (8 19:02 -0500)
committerAleksey Kliger (λgeek) <akliger@gmail.com>
Tue, 2 Jan 2018 17:05:48 +0000 (2 12:05 -0500)
tree9caedb8ed4b27f2570e9ab37c0f49d8a1fc2235d
parent6102b9538555180cea57b92c3969d324cedf2f7f
[sre] Emit a memberref token for fields,methods of a gtd

This can happen when emitting code like:
```
  class Foo<T> {
    T elt;
    public T getter () {
      return elt;  // ILGenerator.Emit (OpCodes.Ldfld, /*FieldBuilder of Foo::elt*/)
    };
  }
```

the old incorrect code emitted a fielddef token for Foo::elt, but it should be a
memberref for Foo<!0>::elt.

Likewise, if we have
```
class Foo<T> {
  public T f () { /*...*/}
  public void g () {
    var x = f (); // ILGenerator.Emit (OpCodes.Call, /* MethodBuilder of Foo::f */)
    /*... */
  }
}
```

Fixes https://github.com/mono/mono/issues/6192

the old incorrect code would emit a fieldref token for Foo::f but it should be
a memberref for Foo<!0>::f
mono/metadata/sre.c