blob: abc1131e80e4b4915a1e29d5f181caa5f488d449 (
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
44
|
//TEST:INTERPRET(filecheck=CHECK):
interface IFoo
{
void test();
};
struct Foo<let GenericValue : uint> : IFoo
{
void test()
{
printf("GenericValue=%d, value=%d\n", GenericValue, value);
}
uint value;
};
void testInterfaceAsParameter(IFoo foo)
{
foo.test();
}
void testInterfaceAsGeneric<T:IFoo>(T foo)
{
foo.test();
}
void main()
{
// CHECK-COUNT-2:GenericValue=0, value=0
Foo<0> foo0 = {0};
testInterfaceAsParameter(foo0);
testInterfaceAsGeneric(foo0);
// CHECK-COUNT-2:GenericValue=1, value=1
Foo<1> foo1 = {1};
testInterfaceAsParameter(foo1);
testInterfaceAsGeneric(foo1);
// CHECK-COUNT-2:GenericValue=2, value=2
Foo<2> foo2 = {2};
testInterfaceAsParameter(foo2);
testInterfaceAsGeneric(foo2);
}
|