mono/mono — pull request #887 by knocte (2014-02-04 18:36:36+00:00)
Title: [AOT] Add gshared types from the local&args too (bxc#17572)

The following example was generating an error when compiled an
ran with Full AOT.

```
public class Foo
{
public Foo() {
var c = new Bar ();
Console.WriteLine ("Foo ctor ", c);
}
}
public class Bar
{
public Bar()
{
Console.WriteLine ("T1:{0},T2:{1}", typeof(T1).FullName, typeof(T2).FullName);
}
}
public class Baz
{
}

class MainClass
{
public static void Main (string[] args)
{
var c = new Foo();
Console.WriteLine ("end");
}
}
```
This is actually not a value-type generic sharing limitation
because the same example, with a field instead of a local
variable in Foo's constructor, works:
```
public class Foo
{
Bar c;
public Foo() {
Console.WriteLine ("Foo ctor ", c);
}
}
public class Bar
{
public Bar()
{
Console.WriteLine ("T1:{0},T2:{1}", typeof(T1).FullName, typeof(T2).FullName);
}
}
public class Baz
{
}

class MainClass
{
public static void Main (string[] args)
{
var c = new Foo();
Console.WriteLine ("end");
}
}
```
The difference between the class Foo in each case can be better
visualized this way:
```
#if !BUG
public Foo() {
var c = new Bar ();
Console.WriteLine ("Foo ctor ", c);
}
#else
Bar c;
public Foo() {
Console.WriteLine ("Foo ctor ", c);
}
#endif
```
By inspecting the types of local variables and arguments of methods
(besides fields), this bug is fixed. It's the first part for bug 17572.
https://bugzilla.xamarin.com/show_bug.cgi?id=17572

This commit is provided under the terms of the X11/MIT licence.