blob: e6466d61413d12c5e0cc14be5cfbad42b9571377 (
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
45
46
47
48
49
50
51
52
|
//TEST:INTERPRET(filecheck=CHECK):
interface IGen<A>
{
associatedtype TB;
TB getVal();
}
struct Foo1<A> : IGen<A>
{
typealias TB = int;
int val = 0;
TB getVal()
{
return val;
}
}
struct Foo2<A> : IGen<A>
{
typealias TB = int;
int val = 0;
TB getVal()
{
return val;
}
}
struct Logic<A1, C1 : IGen<A1>, C2 : IGen<A1>>
{
int val = 0;
}
extension<A, C1, C2> Logic<A, C1, C2>
where C1 : IGen<A>
where C2 : IGen<A>
where C1.TB == C2.TB
{
[mutating]
void setVal(int dataIn)
{
val = dataIn;
}
}
void main()
{
Logic<int, Foo1<int>, Foo2<int>> logic;
logic.setVal(42);
int result = logic.val;
printf("Result: %d\n", result);
// CHECK: Result: 42
}
|