summaryrefslogtreecommitdiff
path: root/tests/delegates/bug659778.vala
blob: 79fa86eff43dfcd694c28942c9d9a0cf3d21c3d9 (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
delegate G DoSomething<G>(G g);

void do_something<G> (DoSomething<G> f) {}

enum TestEnum {
	T;
	public void f() {
		do_something<TestEnum> ((x) => {
			switch (this) {
			case T:
				return T;
			default:
				assert_not_reached ();
			}
        });
	}
	public void g(int i) {
		do_something<TestEnum> ((x) => {
			switch (this) {
			case T:
				i++;
				return T;
			default:
				assert_not_reached ();
			}
		});
	}
}

class Test {
	public void f() {
		do_something<TestEnum> (g);
		do_something<int> (h);
	}
	[CCode (instance_pos = -1)]
	private TestEnum g(TestEnum i) {
		return i;
	}
	[CCode (instance_pos = -1)]
	private int h(int i) {
		return i;
	}
}

int main() {
	TestEnum t = TestEnum.T;
	t.f ();
	t.g (0);
	Test t2 = new Test ();
	t2.f ();
	return 0;
}