From d89b9df567f96c87dc133b121655e08bcb30c84b Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 30 Nov 2015 10:30:03 -0800 Subject: [PATCH] Update baseline with new error message number and fix space and comment --- src/compiler/checker.ts | 9 ++++----- .../checkSuperCallBeforeThisAccessing1.types | 8 ++++---- .../checkSuperCallBeforeThisAccessing2.errors.txt | 4 ++-- .../checkSuperCallBeforeThisAccessing3.types | 8 ++++---- .../checkSuperCallBeforeThisAccessing4.types | 12 ++++++------ .../checkSuperCallBeforeThisAccessing5.errors.txt | 4 ++-- .../checkSuperCallBeforeThisAccessing6.types | 6 +++--- .../checkSuperCallBeforeThisAccessing7.types | 6 +++--- .../checkSuperCallBeforeThisAccessing8.errors.txt | 4 ++-- .../derivedClassParameterProperties.errors.txt | 4 ++-- .../derivedClassSuperCallsWithThisArg.errors.txt | 4 ++-- .../reference/thisInInvalidContexts.errors.txt | 6 +++--- .../thisInInvalidContextsExternalModule.errors.txt | 6 +++--- tests/baselines/reference/thisInSuperCall.errors.txt | 4 ++-- .../baselines/reference/thisInSuperCall2.errors.txt | 4 ++-- 15 files changed, 44 insertions(+), 45 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3c9b32a238f..f51b59df3b5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7240,7 +7240,6 @@ namespace ts { let container = getThisContainer(node, /* includeArrowFunctions */ true); let needToCaptureLexicalThis = false; - if (container.kind === SyntaxKind.Constructor) { // Keep track of whether we have seen "super" before encounter "this" so that // we can report appropriate error later in checkConstructorDeclaration @@ -7251,7 +7250,7 @@ namespace ts { // (()=>this); // No Error // super(); // } - let nodeLinks = getNodeLinks(container); + const nodeLinks = getNodeLinks(container); nodeLinks.flags |= NodeCheckFlags.HasSeenThisCall; } @@ -10199,10 +10198,10 @@ namespace ts { const signature = getResolvedSignature(node); if (node.expression.kind === SyntaxKind.SuperKeyword) { - let containgFunction = getContainingFunction(node.expression); + const containgFunction = getContainingFunction(node.expression); if (containgFunction && containgFunction.kind === SyntaxKind.Constructor) { - let nodeLinks = getNodeLinks(containgFunction); + const nodeLinks = getNodeLinks(containgFunction); if (!(nodeLinks.flags & NodeCheckFlags.HasSeenThisCall)) { nodeLinks.flags |= NodeCheckFlags.HasSeenSuperBeforeThis; } @@ -11835,7 +11834,7 @@ namespace ts { markThisReferencesAsErrors(superCallStatement.expression); } } - else if (!(getNodeCheckFlags(node) & NodeCheckFlags.HasSeenSuperBeforeThis)){ + else if (!(getNodeCheckFlags(node) & NodeCheckFlags.HasSeenSuperBeforeThis)) { // In ES6, super inside constructor of class-declaration has to precede "this" accessing error(superCallStatement, Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing1.types b/tests/baselines/reference/checkSuperCallBeforeThisAccessing1.types index f6114d28997..d734b0c6ad0 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing1.types +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing1.types @@ -15,17 +15,17 @@ class Derived extends Based { >super : typeof Based this; ->this : Derived +>this : this this.x = 10; >this.x = 10 : number >this.x : number ->this : Derived +>this : this >x : number >10 : number var that = this; ->that : Derived ->this : Derived +>that : this +>this : this } } diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing2.errors.txt b/tests/baselines/reference/checkSuperCallBeforeThisAccessing2.errors.txt index 6fdb2e3e394..e48f43c8662 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing2.errors.txt +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/checkSuperCallBeforeThisAccessing2.ts(6,9): error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/compiler/checkSuperCallBeforeThisAccessing2.ts(6,9): error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class. ==== tests/cases/compiler/checkSuperCallBeforeThisAccessing2.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/compiler/checkSuperCallBeforeThisAccessing2.ts(6,9): error TS17006: this.x = 100; super(); ~~~~~~~~ -!!! error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class. this.x = 10; var that = this; } diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.types b/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.types index 45077a6fe5e..c4e9e15ed8e 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.types +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.types @@ -20,7 +20,7 @@ class Derived extends Based { this.y = true; >this.y = true : boolean >this.y : boolean ->this : innver +>this : this >y : boolean >true : boolean } @@ -32,12 +32,12 @@ class Derived extends Based { this.x = 10; >this.x = 10 : number >this.x : number ->this : Derived +>this : this >x : number >10 : number var that = this; ->that : Derived ->this : Derived +>that : this +>this : this } } diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing4.types b/tests/baselines/reference/checkSuperCallBeforeThisAccessing4.types index 965d09a4109..f42a0ac8563 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing4.types +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing4.types @@ -15,14 +15,14 @@ class Derived extends Based { >() => { this; // No error } : () => void this; // No error ->this : Derived +>this : this }); () => { >() => { this; // No error } : () => void this; // No error ->this : Derived +>this : this }; (() => { @@ -31,7 +31,7 @@ class Derived extends Based { >() => { this; // No error } : () => void this; // No error ->this : Derived +>this : this })(); super(); @@ -45,12 +45,12 @@ class Derived extends Based { this.x = 10; >this.x = 10 : number >this.x : number ->this : Derived +>this : this >x : number >10 : number var that = this; ->that : Derived ->this : Derived +>that : this +>this : this } } diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing5.errors.txt b/tests/baselines/reference/checkSuperCallBeforeThisAccessing5.errors.txt index edd7745a03c..1258101cffc 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing5.errors.txt +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/checkSuperCallBeforeThisAccessing5.ts(5,9): error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/compiler/checkSuperCallBeforeThisAccessing5.ts(5,9): error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class. ==== tests/cases/compiler/checkSuperCallBeforeThisAccessing5.ts (1 errors) ==== @@ -8,6 +8,6 @@ tests/cases/compiler/checkSuperCallBeforeThisAccessing5.ts(5,9): error TS17006: constructor() { super(this.x); ~~~~~~~~~~~~~~ -!!! error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17008: '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/checkSuperCallBeforeThisAccessing6.types b/tests/baselines/reference/checkSuperCallBeforeThisAccessing6.types index 8e2d285d85b..826dab0c400 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing6.types +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing6.types @@ -12,9 +12,9 @@ class Super extends Base { constructor() { (() => this); // No Error ->(() => this) : () => Super ->() => this : () => Super ->this : Super +>(() => this) : () => this +>() => this : () => this +>this : this super(); >super() : void diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing7.types b/tests/baselines/reference/checkSuperCallBeforeThisAccessing7.types index fa5e7dbe857..11d2ab26d20 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing7.types +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing7.types @@ -15,8 +15,8 @@ class Super extends Base { super((() => this)); // No error >super((() => this)) : void >super : typeof Base ->(() => this) : () => Super ->() => this : () => Super ->this : Super +>(() => this) : () => this +>() => this : () => this +>this : this } } diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing8.errors.txt b/tests/baselines/reference/checkSuperCallBeforeThisAccessing8.errors.txt index 39db87d41a1..7a00a4f0130 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing8.errors.txt +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing8.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/checkSuperCallBeforeThisAccessing8.ts(8,9): error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/compiler/checkSuperCallBeforeThisAccessing8.ts(8,9): error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class. ==== tests/cases/compiler/checkSuperCallBeforeThisAccessing8.ts (1 errors) ==== @@ -11,6 +11,6 @@ tests/cases/compiler/checkSuperCallBeforeThisAccessing8.ts(8,9): error TS17006: var that = this; super(); ~~~~~~~~ -!!! error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17008: '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/derivedClassParameterProperties.errors.txt b/tests/baselines/reference/derivedClassParameterProperties.errors.txt index c5d853dec56..37f272db082 100644 --- a/tests/baselines/reference/derivedClassParameterProperties.errors.txt +++ b/tests/baselines/reference/derivedClassParameterProperties.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(17,9): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(32,9): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(49,9): error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(49,9): error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(59,9): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassParameterProperties.ts(82,9): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties. @@ -60,7 +60,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassP var b = 2; super(); // error: "super" has to be called before "this" accessing ~~~~~~~~ -!!! error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class. } } diff --git a/tests/baselines/reference/derivedClassSuperCallsWithThisArg.errors.txt b/tests/baselines/reference/derivedClassSuperCallsWithThisArg.errors.txt index e72dbe293e9..0190a659166 100644 --- a/tests/baselines/reference/derivedClassSuperCallsWithThisArg.errors.txt +++ b/tests/baselines/reference/derivedClassSuperCallsWithThisArg.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsWithThisArg.ts(8,9): error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsWithThisArg.ts(8,9): error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsWithThisArg.ts(14,15): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsWithThisArg.ts(20,21): error TS2332: 'this' cannot be referenced in current location. @@ -13,7 +13,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS constructor() { super(this); // ok ~~~~~~~~~~~~ -!!! error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class. } } diff --git a/tests/baselines/reference/thisInInvalidContexts.errors.txt b/tests/baselines/reference/thisInInvalidContexts.errors.txt index 09fa952e2c2..d74db892019 100644 --- a/tests/baselines/reference/thisInInvalidContexts.errors.txt +++ b/tests/baselines/reference/thisInInvalidContexts.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(3,16): error TS2334: 'this' cannot be referenced in a static property initializer. -tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(14,9): error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(14,9): error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(22,15): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(28,13): error TS2331: 'this' cannot be referenced in a module or namespace body. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(36,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface. @@ -8,7 +8,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(44,9): tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(45,9): error TS2332: 'this' cannot be referenced in current location. -==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts (7 errors) ==== +==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts (8 errors) ==== //'this' in static member initializer class ErrClass1 { static t = this; // Error @@ -26,7 +26,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(45,9): constructor() { super(this); // Error ~~~~~~~~~~~~ -!!! error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class. } } diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt index a6c5a2ff102..89472de5d1a 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(3,16): error TS2334: 'this' cannot be referenced in a static property initializer. -tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(14,9): error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(14,9): error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(22,15): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(28,13): error TS2331: 'this' cannot be referenced in a module or namespace body. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(36,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface. @@ -9,7 +9,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalMod tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(48,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file. -==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts (8 errors) ==== +==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts (9 errors) ==== //'this' in static member initializer class ErrClass1 { static t = this; // Error @@ -27,7 +27,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalMod constructor() { super(this); // error: "super" has to be called before "this" accessing ~~~~~~~~~~~~ -!!! error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class. } } diff --git a/tests/baselines/reference/thisInSuperCall.errors.txt b/tests/baselines/reference/thisInSuperCall.errors.txt index ea4b6fd742a..f0fc5854123 100644 --- a/tests/baselines/reference/thisInSuperCall.errors.txt +++ b/tests/baselines/reference/thisInSuperCall.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/thisInSuperCall.ts(7,9): error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/compiler/thisInSuperCall.ts(7,9): error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/compiler/thisInSuperCall.ts(14,15): error TS2332: 'this' cannot be referenced in current location. tests/cases/compiler/thisInSuperCall.ts(20,15): error TS2332: 'this' cannot be referenced in current location. @@ -12,7 +12,7 @@ tests/cases/compiler/thisInSuperCall.ts(20,15): error TS2332: 'this' cannot be r constructor() { super(this); // error: "super" has to be called before "this" accessing ~~~~~~~~~~~~ -!!! error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class. } } diff --git a/tests/baselines/reference/thisInSuperCall2.errors.txt b/tests/baselines/reference/thisInSuperCall2.errors.txt index 7130ee8deb8..11ea23d020c 100644 --- a/tests/baselines/reference/thisInSuperCall2.errors.txt +++ b/tests/baselines/reference/thisInSuperCall2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/thisInSuperCall2.ts(8,9): error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +tests/cases/compiler/thisInSuperCall2.ts(8,9): error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/compiler/thisInSuperCall2.ts(16,15): error TS2332: 'this' cannot be referenced in current location. @@ -12,7 +12,7 @@ tests/cases/compiler/thisInSuperCall2.ts(16,15): error TS2332: 'this' cannot be constructor() { super(this); // error: "super" has to be called before "this" accessing ~~~~~~~~~~~~ -!!! error TS17006: 'super' must be called before accessing 'this' in the constructor of a derived class. +!!! error TS17008: 'super' must be called before accessing 'this' in the constructor of a derived class. } }