Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gtest-126.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: aae93a86ad18454eb35e9d6c7954e805a91dc060 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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;
  }
 
  public 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);
  }
}