blob: 7ec699ee956229f640fff54e97b1bdcdf819ec5b (
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
|
interface IA : IB
{
}
interface IB
{
}
class A<T> where T : IA
{
}
class C
{
public virtual void Foo<T> (A<T> t) where T : IA
{
}
}
class D : C
{
public override void Foo<T> (A<T> t)
{
}
public static int Main ()
{
new D ();
var m = typeof (D).GetMethod ("Foo");
var ga = m.GetGenericArguments() [0];
var tpConstraints = ga.GetGenericParameterConstraints();
if (tpConstraints.Length != 1)
return 1;
if (tpConstraints [0] != typeof (IA))
return 2;
return 0;
}
}
|