New test.
authorMartin Baulig <martin@novell.com>
Tue, 22 Feb 2005 19:04:56 +0000 (19:04 -0000)
committerMartin Baulig <martin@novell.com>
Tue, 22 Feb 2005 19:04:56 +0000 (19:04 -0000)
svn path=/trunk/mcs/; revision=41054

mcs/tests/Makefile
mcs/tests/gen-126.cs [new file with mode: 0644]

index 54b41c98e1645d1f028a13d5cc5536ab08a64405..f2ef2a669885be6d1c233ba18f208759c0f93031 100644 (file)
@@ -117,7 +117,7 @@ TEST_SOURCES_net_2_0 = \
        gen-91  gen-92  gen-93  gen-94  gen-95  gen-96  gen-97                  gen-100 \
        gen-101 gen-102 gen-103 gen-104 gen-105 gen-106 gen-107 gen-108 gen-109 gen-110 \
        gen-111 gen-112 gen-113 gen-114 gen-115 gen-116 gen-117 gen-118 gen-119 gen-120 \
-       gen-121 gen-122 gen-123 gen-124 gen-125
+       gen-121 gen-122 gen-123 gen-124 gen-125 gen-126
 
 # gen-72 fails after the runtime changes in r40305
 TEST_EXCLUDES_net_2_0 = $(NEW_TEST_SOURCES_common) gen-72
diff --git a/mcs/tests/gen-126.cs b/mcs/tests/gen-126.cs
new file mode 100644 (file)
index 0000000..9a38f03
--- /dev/null
@@ -0,0 +1,43 @@
+using System.Collections.Generic;
+
+// comment this line to see another bug in gmcs (unrelated)
+interface IB { bool foo (); }
+
+
+class B : IB { public bool foo () { return true; } }
+
+interface Filter <T> where T : IB {
+  T Is (IB x);
+
+}
+
+struct K : IB {
+  public bool foo () { return false; }
+
+}
+
+class MyFilter : Filter <K> {
+  public K Is (IB x) { return new K(); }
+}
+
+class MyBFilter : Filter <B> {
+  public B Is (IB x) { return new B(); }
+}
+
+class M {
+  static List<T> foo1 <T> (Filter <T> x) where T : IB {
+    List <T> result = new List <T>();
+    T maybe = x.Is (new B());
+    if (maybe != null)
+      result.Add (maybe);
+    return result;
+  }
+  static void Main () {
+       MyFilter m = new MyFilter ();
+        System.Console.WriteLine (foo1 <K> (m).Count);
+        MyBFilter mb = new MyBFilter ();
+        System.Console.WriteLine (foo1 <B> (mb).Count);
+  }
+}