Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/compiler/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,23 @@ namespace ts {

// Utilities

export function restoreEnclosingLabel(node: Statement, outermostLabeledStatement: LabeledStatement, afterRestoreLabelCallback?: (node: LabeledStatement) => void): Statement {
if (!outermostLabeledStatement) {
return node;
}
const updated = updateLabel(
outermostLabeledStatement,
outermostLabeledStatement.label,
outermostLabeledStatement.statement.kind === SyntaxKind.LabeledStatement
? restoreEnclosingLabel(node, <LabeledStatement>outermostLabeledStatement.statement)
: node
);
if (afterRestoreLabelCallback) {
afterRestoreLabelCallback(outermostLabeledStatement);
}
return updated;
}

export interface CallBinding {
target: LeftHandSideExpression;
thisArg: Expression;
Expand Down
948 changes: 553 additions & 395 deletions src/compiler/transformers/es2015.ts

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,17 @@ namespace ts {
return false;
}

export function unwrapInnermostStatmentOfLabel(node: LabeledStatement, beforeUnwrapLabelCallback?: (node: LabeledStatement) => void) {
while (true) {
if (beforeUnwrapLabelCallback) {
beforeUnwrapLabelCallback(node);
}
if (node.statement.kind !== SyntaxKind.LabeledStatement) {
return node.statement;
}
node = <LabeledStatement>node.statement;
}
}

export function isFunctionBlock(node: Node) {
return node && node.kind === SyntaxKind.Block && isFunctionLike(node.parent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var A = (function () {
var B = (function (_super) {
__extends(B, _super);
function B() {
var _this = _super.call(this, function () { return _super.blah.call(_this); }) || this;
var _this = _super.call(this, function () { return _super.prototype.blah.call(_this); }) || this;
return _this;
}
return B;
Expand Down
6 changes: 3 additions & 3 deletions tests/baselines/reference/superAccess2.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ var Q = (function (_super) {
__extends(Q, _super);
// Super is not allowed in constructor args
function Q(z, zz, zzz) {
if (z === void 0) { z = _super.; }
if (zz === void 0) { zz = _super.; }
if (zzz === void 0) { zzz = function () { return _super.; }; }
if (z === void 0) { z = _super.prototype.; }
if (zz === void 0) { zz = _super.prototype.; }
if (zzz === void 0) { zzz = function () { return _super.prototype.; }; }
var _this = _super.call(this) || this;
_this.z = z;
_this.xx = _super.prototype.;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/superInConstructorParam1.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var B = (function () {
var C = (function (_super) {
__extends(C, _super);
function C(a) {
if (a === void 0) { a = _super.foo.call(_this); }
if (a === void 0) { a = _super.prototype.foo.call(_this); }
var _this;
return _this;
}
Expand Down
12 changes: 6 additions & 6 deletions tests/baselines/reference/superInObjectLiterals_ES5.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ var obj = {
}
},
method: function () {
_super.prototype.method.call(this);
_super.method.call(this);
},
get prop() {
_super.prototype.method.call(this);
_super.method.call(this);
return 10;
},
set prop(value) {
_super.prototype.method.call(this);
_super.method.call(this);
},
p1: function () {
_super.method.call(this);
Expand Down Expand Up @@ -110,14 +110,14 @@ var B = (function (_super) {
}
},
method: function () {
_super.prototype.method.call(this);
_super.method.call(this);
},
get prop() {
_super.prototype.method.call(this);
_super.method.call(this);
return 10;
},
set prop(value) {
_super.prototype.method.call(this);
_super.method.call(this);
},
p1: function () {
_super.method.call(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var A = (function () {
var B = (function (_super) {
__extends(B, _super);
function B() {
var _this = _super.call(this, _super.blah.call(_this)) || this;
var _this = _super.call(this, _super.prototype.blah.call(_this)) || this;
return _this;
}
return B;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var C1 = (function (_super) {
var C2 = (function (_super) {
__extends(C2, _super);
function C2() {
var _this = _super.call(this, _super.x.call(_this)) || this;
var _this = _super.call(this, _super.prototype.x.call(_this)) || this;
return _this;
}
return C2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ var ObjectLiteral;
var ThisInObjectLiteral = {
_foo: '1',
get foo() {
return _super.prototype._foo;
return _super._foo;
},
set foo(value) {
_super.prototype._foo = value;
_super._foo = value;
},
test: function () {
return _super._foo;
Expand All @@ -62,7 +62,7 @@ var SuperObjectTest = (function (_super) {
SuperObjectTest.prototype.testing = function () {
var test = {
get F() {
return _super.prototype.test.call(this);
return _super.test.call(this);
}
};
};
Expand Down