-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample4.txt
More file actions
46 lines (36 loc) · 782 Bytes
/
Copy pathsample4.txt
File metadata and controls
46 lines (36 loc) · 782 Bytes
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
interface Super {
.super(): int;
}
struct Sub1() {
as Super {
::super(): int -> 3;
}
.sub1(): bool -> true;
}
struct Sub2() {
as Super {
::super(): int -> 5;
}
.sub2(): bool -> true;
}
fn accept_super(value: Super) {
value.super();
}
fn accept_sub1(value: Sub1) {
value.super();
value.sub1();
}
fn call_super(super: Super, f: Super => void) {
f(super);
}
fn call_sub1(sub1: Sub1, f: Sub1 => void) {
f(sub1);
}
fn main(super: Super, sub1: Sub1, sub2: Sub2) {
call_super(sub2, accept_sub1); // should be an error
call_sub1(sub1, accept_super); // shouldn't be an error
accept_super(sub1);
let test = (x: int, y: bool) -> {};
accept_test(test);
}
fn accept_test(test: (int, bool) => void) {}