using System; public class ClassA {} public class ClassB {} public delegate string[] StringArrayDelegate (); public class Gen { static bool checkArr (Array arr, int length) { if (arr.GetType () != typeof (S[])) return false; if (arr.Length != length) return false; return true; } public bool test () { return checkArr (newArr (), myLength ()); } public virtual int myLength () { return 3; } public virtual S[] newArr () { return new S[3]; } } public class GenSub : Gen { public override int myLength () { return 4; } public override S[] newArr () { return new S[4]; } } public class GenSubSub : GenSub { public override int myLength () { return 5; } public override S[] newArr () { return new S[5]; } public static S[] staticNewArr () { return new S[5]; } } public class main { public static int Main () { Gen ga = new Gen (); Gen gsa = new GenSub (); Gen gss = new GenSubSub (); int i; for (i = 0; i < 100; ++i) { if (!ga.test ()) return 1; if (!gsa.test ()) return 1; if (!gss.test ()) return 1; StringArrayDelegate sad = new StringArrayDelegate (GenSubSub.staticNewArr); string[] arr = sad (); if (arr.GetType () != typeof (string[])) return 1; if (arr.Length != 5) return 1; sad = new StringArrayDelegate (gss.newArr); arr = sad (); if (arr.GetType () != typeof (string[])) return 1; if (arr.Length != 5) return 1; } /* A test for rebuilding generic virtual thunks */ for (i = 0; i < 1000; ++i) { object o = ga.newArr (); if (!(o is string[])) return 2; } for (i = 0; i < 1000; ++i) { object o = ga.newArr (); if (!(o is object[])) return 2; } return 0; } }