From 3e850156da8be9b6763abfe44d8e4062a07c0a9a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 31 Aug 2017 10:15:42 -0700 Subject: [PATCH] Propagate isRestParameter through symbol instantiation (#18087) * Add repro from #17666 * Actually use repro from issue, propegate isRestParameter on instantiation --- src/compiler/checker.ts | 3 ++ .../reference/superNoModifiersCrash.js | 42 +++++++++++++++++++ .../reference/superNoModifiersCrash.symbols | 25 +++++++++++ .../reference/superNoModifiersCrash.types | 32 ++++++++++++++ tests/cases/compiler/superNoModifiersCrash.ts | 14 +++++++ 5 files changed, 116 insertions(+) create mode 100644 tests/baselines/reference/superNoModifiersCrash.js create mode 100644 tests/baselines/reference/superNoModifiersCrash.symbols create mode 100644 tests/baselines/reference/superNoModifiersCrash.types create mode 100644 tests/cases/compiler/superNoModifiersCrash.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a73a29d648d..269666d7b94 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8168,6 +8168,9 @@ namespace ts { if (symbol.valueDeclaration) { result.valueDeclaration = symbol.valueDeclaration; } + if ((symbol as TransientSymbol).isRestParameter) { + result.isRestParameter = (symbol as TransientSymbol).isRestParameter; + } return result; } diff --git a/tests/baselines/reference/superNoModifiersCrash.js b/tests/baselines/reference/superNoModifiersCrash.js new file mode 100644 index 00000000000..be9f6eb4481 --- /dev/null +++ b/tests/baselines/reference/superNoModifiersCrash.js @@ -0,0 +1,42 @@ +//// [File.js] +class Parent { + initialize() { + super.initialize(...arguments) + return this.asdf = '' + } + } + +class Child extends Parent { + initialize() { + } +} + +//// [File.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 Parent = /** @class */ (function () { + function Parent() { + } + Parent.prototype.initialize = function () { + _super.prototype.initialize.apply(this, arguments); + return this.asdf = ''; + }; + return Parent; +}()); +var Child = /** @class */ (function (_super) { + __extends(Child, _super); + function Child() { + return _super !== null && _super.apply(this, arguments) || this; + } + Child.prototype.initialize = function () { + }; + return Child; +}(Parent)); diff --git a/tests/baselines/reference/superNoModifiersCrash.symbols b/tests/baselines/reference/superNoModifiersCrash.symbols new file mode 100644 index 00000000000..59f56aaa59e --- /dev/null +++ b/tests/baselines/reference/superNoModifiersCrash.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/File.js === +class Parent { +>Parent : Symbol(Parent, Decl(File.js, 0, 0)) + + initialize() { +>initialize : Symbol(Parent.initialize, Decl(File.js, 0, 14)) + + super.initialize(...arguments) +>arguments : Symbol(arguments) + + return this.asdf = '' +>this.asdf : Symbol(Parent.asdf, Decl(File.js, 3, 14)) +>this : Symbol(Parent, Decl(File.js, 0, 0)) +>asdf : Symbol(Parent.asdf, Decl(File.js, 3, 14)) + } + } + +class Child extends Parent { +>Child : Symbol(Child, Decl(File.js, 5, 3)) +>Parent : Symbol(Parent, Decl(File.js, 0, 0)) + + initialize() { +>initialize : Symbol(Child.initialize, Decl(File.js, 7, 28)) + } +} diff --git a/tests/baselines/reference/superNoModifiersCrash.types b/tests/baselines/reference/superNoModifiersCrash.types new file mode 100644 index 00000000000..231e4a661bb --- /dev/null +++ b/tests/baselines/reference/superNoModifiersCrash.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/File.js === +class Parent { +>Parent : Parent + + initialize() { +>initialize : (...args: any[]) => string + + super.initialize(...arguments) +>super.initialize(...arguments) : any +>super.initialize : any +>super : any +>initialize : any +>...arguments : any +>arguments : IArguments + + return this.asdf = '' +>this.asdf = '' : "" +>this.asdf : string +>this : this +>asdf : string +>'' : "" + } + } + +class Child extends Parent { +>Child : Child +>Parent : Parent + + initialize() { +>initialize : () => void + } +} diff --git a/tests/cases/compiler/superNoModifiersCrash.ts b/tests/cases/compiler/superNoModifiersCrash.ts new file mode 100644 index 00000000000..4e83184364a --- /dev/null +++ b/tests/cases/compiler/superNoModifiersCrash.ts @@ -0,0 +1,14 @@ +// @allowjs: true +// @outDir: ../ +// @filename: File.js +class Parent { + initialize() { + super.initialize(...arguments) + return this.asdf = '' + } + } + +class Child extends Parent { + initialize() { + } +} \ No newline at end of file