[mcs] Fixes codegen for pattern probing with value-type variables
[mono.git] / mcs / tests / test-pattern-12.cs
1 using System;
2 using System.Collections.Generic;
3
4 class X
5 {
6         public static int Main ()
7         {
8                 foreach (var x in Test1 ("2"))
9                 {
10                         Console.WriteLine (x);
11                         return 1;
12                 }
13
14                 foreach (var x in Test2 (2))
15                 {
16                         Console.WriteLine (x);
17                         return 2;
18                 }
19
20                 return 0;
21         }
22
23         public static IEnumerable<object> Test1 (object expr)
24         {
25                 if (expr is short list)
26                 {
27                         yield return "list.Length";
28                 }
29         }
30
31         public static IEnumerable<object> Test2 (object expr)
32         {
33                 if (expr is string list)
34                 {
35                         yield return "list.Length";
36                 }
37         }
38 }