Test that super is tracked in control flow

This commit is contained in:
Nathan Shively-Sanders
2017-03-31 14:18:42 -07:00
parent a4a7669a4b
commit b28975dc03
4 changed files with 96 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
//// [controlFlowSuperPropertyAccess.ts]
class B {
protected m?(): void;
}
class C extends B {
body() {
super.m && super.m();
}
}
//// [controlFlowSuperPropertyAccess.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var B = (function () {
function B() {
}
return B;
}());
var C = (function (_super) {
__extends(C, _super);
function C() {
return _super !== null && _super.apply(this, arguments) || this;
}
C.prototype.body = function () {
_super.prototype.m && _super.prototype.m.call(this);
};
return C;
}(B));

View File

@@ -0,0 +1,24 @@
=== tests/cases/conformance/controlFlow/controlFlowSuperPropertyAccess.ts ===
class B {
>B : Symbol(B, Decl(controlFlowSuperPropertyAccess.ts, 0, 0))
protected m?(): void;
>m : Symbol(B.m, Decl(controlFlowSuperPropertyAccess.ts, 0, 9))
}
class C extends B {
>C : Symbol(C, Decl(controlFlowSuperPropertyAccess.ts, 2, 1))
>B : Symbol(B, Decl(controlFlowSuperPropertyAccess.ts, 0, 0))
body() {
>body : Symbol(C.body, Decl(controlFlowSuperPropertyAccess.ts, 3, 19))
super.m && super.m();
>super.m : Symbol(B.m, Decl(controlFlowSuperPropertyAccess.ts, 0, 9))
>super : Symbol(B, Decl(controlFlowSuperPropertyAccess.ts, 0, 0))
>m : Symbol(B.m, Decl(controlFlowSuperPropertyAccess.ts, 0, 9))
>super.m : Symbol(B.m, Decl(controlFlowSuperPropertyAccess.ts, 0, 9))
>super : Symbol(B, Decl(controlFlowSuperPropertyAccess.ts, 0, 0))
>m : Symbol(B.m, Decl(controlFlowSuperPropertyAccess.ts, 0, 9))
}
}

View File

@@ -0,0 +1,26 @@
=== tests/cases/conformance/controlFlow/controlFlowSuperPropertyAccess.ts ===
class B {
>B : B
protected m?(): void;
>m : (() => void) | undefined
}
class C extends B {
>C : C
>B : B
body() {
>body : () => void
super.m && super.m();
>super.m && super.m() : void | undefined
>super.m : (() => void) | undefined
>super : B
>m : (() => void) | undefined
>super.m() : void
>super.m : () => void
>super : B
>m : () => void
}
}

View File

@@ -0,0 +1,9 @@
// @strictNullChecks: true
class B {
protected m?(): void;
}
class C extends B {
body() {
super.m && super.m();
}
}