[mcs] Fixes codegen for pattern probing with value-type variables
[mono.git] / mcs / tests / test-pattern-12.cs
diff --git a/mcs/tests/test-pattern-12.cs b/mcs/tests/test-pattern-12.cs
new file mode 100644 (file)
index 0000000..19f39f1
--- /dev/null
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+
+class X
+{
+       public static int Main ()
+       {
+               foreach (var x in Test1 ("2"))
+               {
+                       Console.WriteLine (x);
+                       return 1;
+               }
+
+               foreach (var x in Test2 (2))
+               {
+                       Console.WriteLine (x);
+                       return 2;
+               }
+
+               return 0;
+       }
+
+       public static IEnumerable<object> Test1 (object expr)
+       {
+               if (expr is short list)
+               {
+                       yield return "list.Length";
+               }
+       }
+
+       public static IEnumerable<object> Test2 (object expr)
+       {
+               if (expr is string list)
+               {
+                       yield return "list.Length";
+               }
+       }
+}
\ No newline at end of file