From f89156bf55a40a6002c2383926b50f250231146c Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 6 Dec 2016 10:47:02 -0800 Subject: [PATCH 1/3] Add error for super property before super --- src/compiler/checker.ts | 48 +++++++++++-------- src/compiler/transformers/es2015.ts | 1 - .../reference/errorSuperCalls.errors.txt | 5 +- .../reference/superAccess2.errors.txt | 11 ++++- .../superInConstructorParam1.errors.txt | 5 +- .../reference/superNewCall1.errors.txt | 5 +- ...rtyInConstructorBeforeSuperCall.errors.txt | 24 ++++++++++ ...perPropertyInConstructorBeforeSuperCall.js | 46 ++++++++++++++++++ .../superWithTypeArgument.errors.txt | 5 +- .../superWithTypeArgument2.errors.txt | 5 +- .../superWithTypeArgument3.errors.txt | 5 +- ...perPropertyInConstructorBeforeSuperCall.ts | 15 ++++++ 12 files changed, 147 insertions(+), 28 deletions(-) create mode 100644 tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.errors.txt create mode 100644 tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.js create mode 100644 tests/cases/conformance/classes/constructorDeclarations/superCalls/superPropertyInConstructorBeforeSuperCall.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 903c8cfda1c20..8c08e9b121b49 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10405,6 +10405,29 @@ namespace ts { return baseConstructorType === nullWideningType; } + function checkThisBeforeSuper(node: Node, container: Node) { + const containingClassDecl = container.parent; + const baseTypeNode = getClassExtendsHeritageClauseElement(containingClassDecl); + + // If a containing class does not have extends clause or the class extends null + // skip checking whether super statement is called before "this" accessing. + if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { + const superCall = getSuperCallInConstructor(container); + + // We should give an error in the following cases: + // - No super-call + // - "this" is accessing before super-call. + // i.e super(this) + // this.x; super(); + // We want to make sure that super-call is done before accessing "this" so that + // "this" is not accessed as a parameter of the super-call. + if (!superCall || superCall.end > node.pos) { + // In ES6, super inside constructor of class-declaration has to precede "this" accessing + error(node, Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); + } + } + } + function checkThisExpression(node: Node): Type { // Stop at the first arrow function so that we can // tell whether 'this' needs to be captured. @@ -10412,26 +10435,7 @@ namespace ts { let needToCaptureLexicalThis = false; if (container.kind === SyntaxKind.Constructor) { - const containingClassDecl = container.parent; - const baseTypeNode = getClassExtendsHeritageClauseElement(containingClassDecl); - - // If a containing class does not have extends clause or the class extends null - // skip checking whether super statement is called before "this" accessing. - if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { - const superCall = getSuperCallInConstructor(container); - - // We should give an error in the following cases: - // - No super-call - // - "this" is accessing before super-call. - // i.e super(this) - // this.x; super(); - // We want to make sure that super-call is done before accessing "this" so that - // "this" is not accessed as a parameter of the super-call. - if (!superCall || superCall.end > node.pos) { - // In ES6, super inside constructor of class-declaration has to precede "this" accessing - error(node, Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); - } - } + checkThisBeforeSuper(node, container); } // Now skip arrow functions to get the "real" owner of 'this'. @@ -10579,6 +10583,10 @@ namespace ts { return unknownType; } + if (!isCallExpression && container.kind === SyntaxKind.Constructor) { + checkThisBeforeSuper(node, container); + } + if ((getModifierFlags(container) & ModifierFlags.Static) || isCallExpression) { nodeCheckFlag = NodeCheckFlags.SuperStatic; } diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index bc9341a4b4f71..c1398f75da605 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -2837,7 +2837,6 @@ namespace ts { // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = createFunctionCall( visitNode(target, visitor, isExpression), visitNode(thisArg, visitor, isExpression), diff --git a/tests/baselines/reference/errorSuperCalls.errors.txt b/tests/baselines/reference/errorSuperCalls.errors.txt index 49bcb4b4d458e..ee2ba6d829d06 100644 --- a/tests/baselines/reference/errorSuperCalls.errors.txt +++ b/tests/baselines/reference/errorSuperCalls.errors.txt @@ -7,6 +7,7 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(26,9): error T tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(30,16): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(34,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(38,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(46,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(46,14): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(58,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(62,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. @@ -14,7 +15,7 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(67,9): error T tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. -==== tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts (14 errors) ==== +==== tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts (15 errors) ==== //super call in class constructor with no base type class NoBase { constructor() { @@ -79,6 +80,8 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error T //super call with type arguments constructor() { super(); + ~~~~~ +!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. super(); diff --git a/tests/baselines/reference/superAccess2.errors.txt b/tests/baselines/reference/superAccess2.errors.txt index d8b39284f6567..c427115574f91 100644 --- a/tests/baselines/reference/superAccess2.errors.txt +++ b/tests/baselines/reference/superAccess2.errors.txt @@ -2,10 +2,13 @@ tests/cases/compiler/superAccess2.ts(7,15): error TS1034: 'super' must be follow tests/cases/compiler/superAccess2.ts(8,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. tests/cases/compiler/superAccess2.ts(8,22): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superAccess2.ts(11,28): error TS2336: 'super' cannot be referenced in constructor arguments. +tests/cases/compiler/superAccess2.ts(11,28): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/compiler/superAccess2.ts(11,33): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superAccess2.ts(11,40): error TS2336: 'super' cannot be referenced in constructor arguments. +tests/cases/compiler/superAccess2.ts(11,40): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/compiler/superAccess2.ts(11,45): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superAccess2.ts(11,59): error TS2336: 'super' cannot be referenced in constructor arguments. +tests/cases/compiler/superAccess2.ts(11,59): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/compiler/superAccess2.ts(11,64): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superAccess2.ts(15,19): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superAccess2.ts(17,15): error TS2339: Property 'y' does not exist on type 'P'. @@ -13,7 +16,7 @@ tests/cases/compiler/superAccess2.ts(20,26): error TS1034: 'super' must be follo tests/cases/compiler/superAccess2.ts(21,15): error TS2339: Property 'x' does not exist on type 'typeof P'. -==== tests/cases/compiler/superAccess2.ts (13 errors) ==== +==== tests/cases/compiler/superAccess2.ts (16 errors) ==== class P { x() { } static y() { } @@ -33,14 +36,20 @@ tests/cases/compiler/superAccess2.ts(21,15): error TS2339: Property 'x' does not constructor(public z = super, zz = super, zzz = () => super) { ~~~~~ !!! error TS2336: 'super' cannot be referenced in constructor arguments. + ~~~~~ +!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. ~~~~~ !!! error TS2336: 'super' cannot be referenced in constructor arguments. + ~~~~~ +!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. ~~~~~ !!! error TS2336: 'super' cannot be referenced in constructor arguments. + ~~~~~ +!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. super(); diff --git a/tests/baselines/reference/superInConstructorParam1.errors.txt b/tests/baselines/reference/superInConstructorParam1.errors.txt index 96735c92547da..1eac79769d8f5 100644 --- a/tests/baselines/reference/superInConstructorParam1.errors.txt +++ b/tests/baselines/reference/superInConstructorParam1.errors.txt @@ -1,8 +1,9 @@ tests/cases/compiler/superInConstructorParam1.ts(8,3): error TS2377: Constructors for derived classes must contain a 'super' call. tests/cases/compiler/superInConstructorParam1.ts(8,19): error TS2336: 'super' cannot be referenced in constructor arguments. +tests/cases/compiler/superInConstructorParam1.ts(8,19): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. -==== tests/cases/compiler/superInConstructorParam1.ts (2 errors) ==== +==== tests/cases/compiler/superInConstructorParam1.ts (3 errors) ==== class B { public foo(): number { return 0; @@ -14,6 +15,8 @@ tests/cases/compiler/superInConstructorParam1.ts(8,19): error TS2336: 'super' ca ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ !!! error TS2336: 'super' cannot be referenced in constructor arguments. + ~~~~~ +!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. } ~~~ !!! error TS2377: Constructors for derived classes must contain a 'super' call. diff --git a/tests/baselines/reference/superNewCall1.errors.txt b/tests/baselines/reference/superNewCall1.errors.txt index 2b104e7d647d3..3dd7435e5c4bf 100644 --- a/tests/baselines/reference/superNewCall1.errors.txt +++ b/tests/baselines/reference/superNewCall1.errors.txt @@ -1,8 +1,9 @@ tests/cases/compiler/superNewCall1.ts(9,5): error TS2377: Constructors for derived classes must contain a 'super' call. tests/cases/compiler/superNewCall1.ts(10,9): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +tests/cases/compiler/superNewCall1.ts(10,13): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. -==== tests/cases/compiler/superNewCall1.ts (2 errors) ==== +==== tests/cases/compiler/superNewCall1.ts (3 errors) ==== class A { constructor(private map: (value: T1) => T2) { @@ -17,6 +18,8 @@ tests/cases/compiler/superNewCall1.ts(10,9): error TS2351: Cannot use 'new' with ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. + ~~~~~ +!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. } ~~~~~ !!! error TS2377: Constructors for derived classes must contain a 'super' call. diff --git a/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.errors.txt b/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.errors.txt new file mode 100644 index 0000000000000..029154e331849 --- /dev/null +++ b/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/classes/constructorDeclarations/superCalls/superPropertyInConstructorBeforeSuperCall.ts(7,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/conformance/classes/constructorDeclarations/superCalls/superPropertyInConstructorBeforeSuperCall.ts(13,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. + + +==== tests/cases/conformance/classes/constructorDeclarations/superCalls/superPropertyInConstructorBeforeSuperCall.ts (2 errors) ==== + class B { + constructor(x?: string) {} + x(): string { return ""; } + } + class C1 extends B { + constructor() { + super.x(); + ~~~~~ +!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. + super(); + } + } + class C2 extends B { + constructor() { + super(super.x()); + ~~~~~ +!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.js b/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.js new file mode 100644 index 0000000000000..15bc0c40f37f5 --- /dev/null +++ b/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.js @@ -0,0 +1,46 @@ +//// [superPropertyInConstructorBeforeSuperCall.ts] +class B { + constructor(x?: string) {} + x(): string { return ""; } +} +class C1 extends B { + constructor() { + super.x(); + super(); + } +} +class C2 extends B { + constructor() { + super(super.x()); + } +} + +//// [superPropertyInConstructorBeforeSuperCall.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var B = (function () { + function B(x) { + } + B.prototype.x = function () { return ""; }; + return B; +}()); +var C1 = (function (_super) { + __extends(C1, _super); + function C1() { + var _this; + _super.prototype.x.call(_this); + _this = _super.call(this) || this; + return _this; + } + return C1; +}(B)); +var C2 = (function (_super) { + __extends(C2, _super); + function C2() { + return _super.call(this, _super.x.call(_this)) || this; + } + return C2; +}(B)); diff --git a/tests/baselines/reference/superWithTypeArgument.errors.txt b/tests/baselines/reference/superWithTypeArgument.errors.txt index d749cbd5157d3..bef02357d353d 100644 --- a/tests/baselines/reference/superWithTypeArgument.errors.txt +++ b/tests/baselines/reference/superWithTypeArgument.errors.txt @@ -1,8 +1,9 @@ tests/cases/compiler/superWithTypeArgument.ts(6,5): error TS2377: Constructors for derived classes must contain a 'super' call. +tests/cases/compiler/superWithTypeArgument.ts(7,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/compiler/superWithTypeArgument.ts(7,14): error TS1034: 'super' must be followed by an argument list or member access. -==== tests/cases/compiler/superWithTypeArgument.ts (2 errors) ==== +==== tests/cases/compiler/superWithTypeArgument.ts (3 errors) ==== class C { } @@ -12,6 +13,8 @@ tests/cases/compiler/superWithTypeArgument.ts(7,14): error TS1034: 'super' must ~~~~~~~~~~~~~~~ super(); ~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. } diff --git a/tests/baselines/reference/superWithTypeArgument2.errors.txt b/tests/baselines/reference/superWithTypeArgument2.errors.txt index 766327c5c813a..4bd7e9608583b 100644 --- a/tests/baselines/reference/superWithTypeArgument2.errors.txt +++ b/tests/baselines/reference/superWithTypeArgument2.errors.txt @@ -1,8 +1,9 @@ tests/cases/compiler/superWithTypeArgument2.ts(6,5): error TS2377: Constructors for derived classes must contain a 'super' call. +tests/cases/compiler/superWithTypeArgument2.ts(7,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/compiler/superWithTypeArgument2.ts(7,14): error TS1034: 'super' must be followed by an argument list or member access. -==== tests/cases/compiler/superWithTypeArgument2.ts (2 errors) ==== +==== tests/cases/compiler/superWithTypeArgument2.ts (3 errors) ==== class C { foo: T; } @@ -12,6 +13,8 @@ tests/cases/compiler/superWithTypeArgument2.ts(7,14): error TS1034: 'super' must ~~~~~~~~~~~~~~~~ super(x); ~~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. } diff --git a/tests/baselines/reference/superWithTypeArgument3.errors.txt b/tests/baselines/reference/superWithTypeArgument3.errors.txt index 323b2958fcba6..a6a59f92a0006 100644 --- a/tests/baselines/reference/superWithTypeArgument3.errors.txt +++ b/tests/baselines/reference/superWithTypeArgument3.errors.txt @@ -1,8 +1,9 @@ tests/cases/compiler/superWithTypeArgument3.ts(7,5): error TS2377: Constructors for derived classes must contain a 'super' call. +tests/cases/compiler/superWithTypeArgument3.ts(8,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/compiler/superWithTypeArgument3.ts(8,14): error TS1034: 'super' must be followed by an argument list or member access. -==== tests/cases/compiler/superWithTypeArgument3.ts (2 errors) ==== +==== tests/cases/compiler/superWithTypeArgument3.ts (3 errors) ==== class C { foo: T; bar(x: U) { } @@ -13,6 +14,8 @@ tests/cases/compiler/superWithTypeArgument3.ts(8,14): error TS1034: 'super' must ~~~~~~~~~~~~~~~ super(); ~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. } diff --git a/tests/cases/conformance/classes/constructorDeclarations/superCalls/superPropertyInConstructorBeforeSuperCall.ts b/tests/cases/conformance/classes/constructorDeclarations/superCalls/superPropertyInConstructorBeforeSuperCall.ts new file mode 100644 index 0000000000000..9d5d4c8c89528 --- /dev/null +++ b/tests/cases/conformance/classes/constructorDeclarations/superCalls/superPropertyInConstructorBeforeSuperCall.ts @@ -0,0 +1,15 @@ +class B { + constructor(x?: string) {} + x(): string { return ""; } +} +class C1 extends B { + constructor() { + super.x(); + super(); + } +} +class C2 extends B { + constructor() { + super(super.x()); + } +} \ No newline at end of file From 9336886fc2340079e38751e8b088f4a8ef9eea2e Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 6 Dec 2016 10:57:52 -0800 Subject: [PATCH 2/3] Added more specific diagnostic message --- src/compiler/checker.ts | 8 ++++---- src/compiler/diagnosticMessages.json | 4 ++++ tests/baselines/reference/superAccess2.errors.txt | 12 ++++++------ .../reference/superInConstructorParam1.errors.txt | 4 ++-- tests/baselines/reference/superNewCall1.errors.txt | 4 ++-- ...erPropertyInConstructorBeforeSuperCall.errors.txt | 8 ++++---- .../reference/superWithTypeArgument.errors.txt | 4 ++-- .../reference/superWithTypeArgument2.errors.txt | 4 ++-- .../reference/superWithTypeArgument3.errors.txt | 4 ++-- 9 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8c08e9b121b49..b7b3043e661b4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10405,7 +10405,7 @@ namespace ts { return baseConstructorType === nullWideningType; } - function checkThisBeforeSuper(node: Node, container: Node) { + function checkThisBeforeSuper(node: Node, container: Node, diagnosticMessage: DiagnosticMessage) { const containingClassDecl = container.parent; const baseTypeNode = getClassExtendsHeritageClauseElement(containingClassDecl); @@ -10423,7 +10423,7 @@ namespace ts { // "this" is not accessed as a parameter of the super-call. if (!superCall || superCall.end > node.pos) { // In ES6, super inside constructor of class-declaration has to precede "this" accessing - error(node, Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); + error(node, diagnosticMessage); } } } @@ -10435,7 +10435,7 @@ namespace ts { let needToCaptureLexicalThis = false; if (container.kind === SyntaxKind.Constructor) { - checkThisBeforeSuper(node, container); + checkThisBeforeSuper(node, container, Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. @@ -10584,7 +10584,7 @@ namespace ts { } if (!isCallExpression && container.kind === SyntaxKind.Constructor) { - checkThisBeforeSuper(node, container); + checkThisBeforeSuper(node, container, Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if ((getModifierFlags(container) & ModifierFlags.Static) || isCallExpression) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4d42c77e5669b..b59921c29489b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3165,6 +3165,10 @@ "category": "Error", "code": 17010 }, + "'super' must be called before accessing a property of 'super' in the constructor of a derived class.": { + "category": "Error", + "code": 17011 + }, "Circularity detected while resolving configuration: {0}": { "category": "Error", diff --git a/tests/baselines/reference/superAccess2.errors.txt b/tests/baselines/reference/superAccess2.errors.txt index c427115574f91..edcd4031c47cd 100644 --- a/tests/baselines/reference/superAccess2.errors.txt +++ b/tests/baselines/reference/superAccess2.errors.txt @@ -2,13 +2,13 @@ tests/cases/compiler/superAccess2.ts(7,15): error TS1034: 'super' must be follow tests/cases/compiler/superAccess2.ts(8,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. tests/cases/compiler/superAccess2.ts(8,22): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superAccess2.ts(11,28): error TS2336: 'super' cannot be referenced in constructor arguments. -tests/cases/compiler/superAccess2.ts(11,28): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/compiler/superAccess2.ts(11,28): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. tests/cases/compiler/superAccess2.ts(11,33): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superAccess2.ts(11,40): error TS2336: 'super' cannot be referenced in constructor arguments. -tests/cases/compiler/superAccess2.ts(11,40): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/compiler/superAccess2.ts(11,40): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. tests/cases/compiler/superAccess2.ts(11,45): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superAccess2.ts(11,59): error TS2336: 'super' cannot be referenced in constructor arguments. -tests/cases/compiler/superAccess2.ts(11,59): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/compiler/superAccess2.ts(11,59): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. tests/cases/compiler/superAccess2.ts(11,64): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superAccess2.ts(15,19): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superAccess2.ts(17,15): error TS2339: Property 'y' does not exist on type 'P'. @@ -37,19 +37,19 @@ tests/cases/compiler/superAccess2.ts(21,15): error TS2339: Property 'x' does not ~~~~~ !!! error TS2336: 'super' cannot be referenced in constructor arguments. ~~~~~ -!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. ~~~~~ !!! error TS2336: 'super' cannot be referenced in constructor arguments. ~~~~~ -!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. ~~~~~ !!! error TS2336: 'super' cannot be referenced in constructor arguments. ~~~~~ -!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. super(); diff --git a/tests/baselines/reference/superInConstructorParam1.errors.txt b/tests/baselines/reference/superInConstructorParam1.errors.txt index 1eac79769d8f5..4220fcb9b0ed4 100644 --- a/tests/baselines/reference/superInConstructorParam1.errors.txt +++ b/tests/baselines/reference/superInConstructorParam1.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/superInConstructorParam1.ts(8,3): error TS2377: Constructors for derived classes must contain a 'super' call. tests/cases/compiler/superInConstructorParam1.ts(8,19): error TS2336: 'super' cannot be referenced in constructor arguments. -tests/cases/compiler/superInConstructorParam1.ts(8,19): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/compiler/superInConstructorParam1.ts(8,19): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. ==== tests/cases/compiler/superInConstructorParam1.ts (3 errors) ==== @@ -16,7 +16,7 @@ tests/cases/compiler/superInConstructorParam1.ts(8,19): error TS17009: 'super' m ~~~~~ !!! error TS2336: 'super' cannot be referenced in constructor arguments. ~~~~~ -!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. } ~~~ !!! error TS2377: Constructors for derived classes must contain a 'super' call. diff --git a/tests/baselines/reference/superNewCall1.errors.txt b/tests/baselines/reference/superNewCall1.errors.txt index 3dd7435e5c4bf..c8fd5c471fbf6 100644 --- a/tests/baselines/reference/superNewCall1.errors.txt +++ b/tests/baselines/reference/superNewCall1.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/superNewCall1.ts(9,5): error TS2377: Constructors for derived classes must contain a 'super' call. tests/cases/compiler/superNewCall1.ts(10,9): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -tests/cases/compiler/superNewCall1.ts(10,13): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/compiler/superNewCall1.ts(10,13): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. ==== tests/cases/compiler/superNewCall1.ts (3 errors) ==== @@ -19,7 +19,7 @@ tests/cases/compiler/superNewCall1.ts(10,13): error TS17009: 'super' must be cal ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. ~~~~~ -!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. } ~~~~~ !!! error TS2377: Constructors for derived classes must contain a 'super' call. diff --git a/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.errors.txt b/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.errors.txt index 029154e331849..407e984c5d1fe 100644 --- a/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.errors.txt +++ b/tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/classes/constructorDeclarations/superCalls/superPropertyInConstructorBeforeSuperCall.ts(7,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. -tests/cases/conformance/classes/constructorDeclarations/superCalls/superPropertyInConstructorBeforeSuperCall.ts(13,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/conformance/classes/constructorDeclarations/superCalls/superPropertyInConstructorBeforeSuperCall.ts(7,9): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. +tests/cases/conformance/classes/constructorDeclarations/superCalls/superPropertyInConstructorBeforeSuperCall.ts(13,15): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. ==== tests/cases/conformance/classes/constructorDeclarations/superCalls/superPropertyInConstructorBeforeSuperCall.ts (2 errors) ==== @@ -11,7 +11,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/superProperty constructor() { super.x(); ~~~~~ -!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. super(); } } @@ -19,6 +19,6 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/superProperty constructor() { super(super.x()); ~~~~~ -!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. } } \ No newline at end of file diff --git a/tests/baselines/reference/superWithTypeArgument.errors.txt b/tests/baselines/reference/superWithTypeArgument.errors.txt index bef02357d353d..5860cb466d93f 100644 --- a/tests/baselines/reference/superWithTypeArgument.errors.txt +++ b/tests/baselines/reference/superWithTypeArgument.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/superWithTypeArgument.ts(6,5): error TS2377: Constructors for derived classes must contain a 'super' call. -tests/cases/compiler/superWithTypeArgument.ts(7,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/compiler/superWithTypeArgument.ts(7,9): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. tests/cases/compiler/superWithTypeArgument.ts(7,14): error TS1034: 'super' must be followed by an argument list or member access. @@ -14,7 +14,7 @@ tests/cases/compiler/superWithTypeArgument.ts(7,14): error TS1034: 'super' must super(); ~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. } diff --git a/tests/baselines/reference/superWithTypeArgument2.errors.txt b/tests/baselines/reference/superWithTypeArgument2.errors.txt index 4bd7e9608583b..473e7f3b7ad70 100644 --- a/tests/baselines/reference/superWithTypeArgument2.errors.txt +++ b/tests/baselines/reference/superWithTypeArgument2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/superWithTypeArgument2.ts(6,5): error TS2377: Constructors for derived classes must contain a 'super' call. -tests/cases/compiler/superWithTypeArgument2.ts(7,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/compiler/superWithTypeArgument2.ts(7,9): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. tests/cases/compiler/superWithTypeArgument2.ts(7,14): error TS1034: 'super' must be followed by an argument list or member access. @@ -14,7 +14,7 @@ tests/cases/compiler/superWithTypeArgument2.ts(7,14): error TS1034: 'super' must super(x); ~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. } diff --git a/tests/baselines/reference/superWithTypeArgument3.errors.txt b/tests/baselines/reference/superWithTypeArgument3.errors.txt index a6a59f92a0006..37e6681d7701c 100644 --- a/tests/baselines/reference/superWithTypeArgument3.errors.txt +++ b/tests/baselines/reference/superWithTypeArgument3.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/superWithTypeArgument3.ts(7,5): error TS2377: Constructors for derived classes must contain a 'super' call. -tests/cases/compiler/superWithTypeArgument3.ts(8,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/compiler/superWithTypeArgument3.ts(8,9): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. tests/cases/compiler/superWithTypeArgument3.ts(8,14): error TS1034: 'super' must be followed by an argument list or member access. @@ -15,7 +15,7 @@ tests/cases/compiler/superWithTypeArgument3.ts(8,14): error TS1034: 'super' must super(); ~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. } From e8024e426609b5249eed19c066bc4b8f7f6a8a29 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 6 Dec 2016 11:19:27 -0800 Subject: [PATCH 3/3] Updated baseline --- tests/baselines/reference/errorSuperCalls.errors.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/baselines/reference/errorSuperCalls.errors.txt b/tests/baselines/reference/errorSuperCalls.errors.txt index ee2ba6d829d06..036367fd44b52 100644 --- a/tests/baselines/reference/errorSuperCalls.errors.txt +++ b/tests/baselines/reference/errorSuperCalls.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(26,9): error T tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(30,16): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(34,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(38,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(46,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(46,9): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(46,14): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(58,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(62,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. @@ -81,7 +81,7 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error T constructor() { super(); ~~~~~ -!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. super();