summaryrefslogtreecommitdiff
path: root/tests/objects/property-delegate-owned.vala
blob: 12c3e4d44df0b72dca5c35df38178b44bd647ab6 (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
53
delegate void FooFunc ();

interface IFoo {
	public abstract FooFunc foo { get; owned set; }
	public abstract FooFunc bar { get; owned set; }
}

class Foo : IFoo {
	FooFunc? _bar;

	public virtual FooFunc foo { get; owned set; }

	public virtual FooFunc bar {
		get {
			return _bar;
		}
		owned set {
			_bar = (owned) value;
		}
	}

	public Foo () {
		foo = () => {};
		bar = () => {};
	}
}

class Bar : Foo {
	FooFunc? _bar;

	public override FooFunc foo { get; owned set; }

	public override FooFunc bar {
		get {
			return _bar;
		}
		owned set {
			_bar = (owned) value;
		}
	}

	public Bar () {
		foo = () => {};
		bar = () => {};
	}
}

void main () {
	var foo = new Foo ();
	foo.foo ();
	var bar = new Bar ();
	bar.bar ();
}