Merge pull request #5390 from kumpera/fix_58637
[mono.git] / mono / tests / generic-stack-traces.2.cs
index c8ae9bf8bf40eb6315b10b0029b78ec9beb1cb8d..499cf9e8d0075fb7e82282a5fd2fa29de18eb3d3 100644 (file)
@@ -13,6 +13,20 @@ public class Gen<T> {
     }
 }
 
+class Foo<T1, T2> {
+
+       public void Throw () {
+               throw new Exception ();
+       }
+
+       public void Throw<T3> () {
+               throw new Exception ();
+       }
+}
+
+class Bar<T> : Foo<object, T> {
+}
+
 public class main {
     public static void callCallStaticCrash<T> () {
        Gen<T> gt = new Gen<T> ();
@@ -24,6 +38,8 @@ public class main {
        for (int i = 0; i < st.FrameCount; ++i) {
            StackFrame sf = st.GetFrame (i);
            MethodBase m = sf.GetMethod ();
+               if (m == null)
+                       continue;
            Type t = m.DeclaringType;
            if (m.IsGenericMethod) {
                Type[] margs = m.GetGenericArguments ();
@@ -70,6 +86,21 @@ public class main {
            if (!test (exc, typeof (Gen<string>)))
                return 1;
        }
+
+       // Exception thrown in inherited method with different generic context
+       // (#509406)
+       try {
+               new Bar <string> ().Throw ();
+       } catch (Exception ex) {
+               Console.WriteLine (new StackTrace (ex));
+       }
+
+       try {
+               new Bar <string> ().Throw<Bar<string>> ();
+       } catch (Exception ex) {
+               Console.WriteLine (new StackTrace (ex));
+       }
+
        return 0;
     }
 }