Skip to content

Commit b28975d

Browse files
committed
Test that super is tracked in control flow
1 parent a4a7669 commit b28975d

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//// [controlFlowSuperPropertyAccess.ts]
2+
class B {
3+
protected m?(): void;
4+
}
5+
class C extends B {
6+
body() {
7+
super.m && super.m();
8+
}
9+
}
10+
11+
12+
//// [controlFlowSuperPropertyAccess.js]
13+
var __extends = (this && this.__extends) || (function () {
14+
var extendStatics = Object.setPrototypeOf ||
15+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
17+
return function (d, b) {
18+
extendStatics(d, b);
19+
function __() { this.constructor = d; }
20+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21+
};
22+
})();
23+
var B = (function () {
24+
function B() {
25+
}
26+
return B;
27+
}());
28+
var C = (function (_super) {
29+
__extends(C, _super);
30+
function C() {
31+
return _super !== null && _super.apply(this, arguments) || this;
32+
}
33+
C.prototype.body = function () {
34+
_super.prototype.m && _super.prototype.m.call(this);
35+
};
36+
return C;
37+
}(B));
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
=== tests/cases/conformance/controlFlow/controlFlowSuperPropertyAccess.ts ===
2+
class B {
3+
>B : Symbol(B, Decl(controlFlowSuperPropertyAccess.ts, 0, 0))
4+
5+
protected m?(): void;
6+
>m : Symbol(B.m, Decl(controlFlowSuperPropertyAccess.ts, 0, 9))
7+
}
8+
class C extends B {
9+
>C : Symbol(C, Decl(controlFlowSuperPropertyAccess.ts, 2, 1))
10+
>B : Symbol(B, Decl(controlFlowSuperPropertyAccess.ts, 0, 0))
11+
12+
body() {
13+
>body : Symbol(C.body, Decl(controlFlowSuperPropertyAccess.ts, 3, 19))
14+
15+
super.m && super.m();
16+
>super.m : Symbol(B.m, Decl(controlFlowSuperPropertyAccess.ts, 0, 9))
17+
>super : Symbol(B, Decl(controlFlowSuperPropertyAccess.ts, 0, 0))
18+
>m : Symbol(B.m, Decl(controlFlowSuperPropertyAccess.ts, 0, 9))
19+
>super.m : Symbol(B.m, Decl(controlFlowSuperPropertyAccess.ts, 0, 9))
20+
>super : Symbol(B, Decl(controlFlowSuperPropertyAccess.ts, 0, 0))
21+
>m : Symbol(B.m, Decl(controlFlowSuperPropertyAccess.ts, 0, 9))
22+
}
23+
}
24+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
=== tests/cases/conformance/controlFlow/controlFlowSuperPropertyAccess.ts ===
2+
class B {
3+
>B : B
4+
5+
protected m?(): void;
6+
>m : (() => void) | undefined
7+
}
8+
class C extends B {
9+
>C : C
10+
>B : B
11+
12+
body() {
13+
>body : () => void
14+
15+
super.m && super.m();
16+
>super.m && super.m() : void | undefined
17+
>super.m : (() => void) | undefined
18+
>super : B
19+
>m : (() => void) | undefined
20+
>super.m() : void
21+
>super.m : () => void
22+
>super : B
23+
>m : () => void
24+
}
25+
}
26+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// @strictNullChecks: true
2+
class B {
3+
protected m?(): void;
4+
}
5+
class C extends B {
6+
body() {
7+
super.m && super.m();
8+
}
9+
}

0 commit comments

Comments
 (0)