-
-
Notifications
You must be signed in to change notification settings - Fork 671
/
Copy pathcall-super.ts
108 lines (84 loc) · 1.31 KB
/
call-super.ts
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// both constructors present
class A {
a: i32 = 1;
constructor() {
assert(this.a == 1);
}
}
class B extends A {
// a: i32 = 3; // FIXME: currently duplicate identifier
b: i32 = 2;
constructor() {
super();
assert(this.a == 1);
assert(this.b == 2);
}
}
function test1(): void {
var b = new B();
assert(b.a == 1);
assert(b.b == 2);
}
test1();
// this constructor present
class C {
a: i32 = 1;
}
class D extends C {
b: i32 = 2;
constructor() {
super();
assert(this.a == 1);
assert(this.b == 2);
}
}
function test2(): void {
var d = new D();
assert(d.a == 1);
assert(d.b == 2);
}
test2();
// super constructor present
class E {
a: i32 = 1;
constructor() {
assert(this.a == 1);
}
}
class F extends E {
b: i32 = 2;
}
function test3(): void {
var f = new F();
assert(f.a == 1);
assert(f.b == 2);
}
test3();
// no constructor present
class G {
a: i32 = 1;
}
class H extends G {
b: i32 = 2;
}
function test4(): void {
var h = new H();
assert(h.a == 1);
assert(h.b == 2);
}
test4();
// this constructor present with fallback allocation (`this` is not accessed)
class I {
a: i32 = 1;
constructor() {
}
}
class J extends I {
b: i32 = 2;
}
function test5(): void {
var h = new J();
assert(h.a == 1);
assert(h.b == 2);
}
test5();