From 7c278d6acc6b5db86b803d0cd21b830deb6f569e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=9B=E5=AE=9A=E8=B0=94=E7=9A=84=E7=8C=AB?= Date: Tue, 6 Nov 2018 03:56:44 +0800 Subject: [PATCH] Fix: build failing due to incorrectly super() call (fixes #398) (#399) --- .../classes/class-one-method-super.result.js | 981 ++++++++++-------- .../6/classes/class-one-method-super.src.js | 4 +- 2 files changed, 548 insertions(+), 437 deletions(-) diff --git a/tests/fixtures/ecma-version/6/classes/class-one-method-super.result.js b/tests/fixtures/ecma-version/6/classes/class-one-method-super.result.js index cedacd90..41f4803d 100644 --- a/tests/fixtures/ecma-version/6/classes/class-one-method-super.result.js +++ b/tests/fixtures/ecma-version/6/classes/class-one-method-super.result.js @@ -1,476 +1,587 @@ module.exports = { - "type": "Program", - "loc": { + "type": "Program", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "range": [ + 0, + 64 + ], + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 63, + "loc": { "start": { - "line": 1, - "column": 0 + "line": 1, + "column": 0 }, "end": { - "line": 5, - "column": 2 + "line": 5, + "column": 1 } - }, - "range": [ + }, + "range": [ 0, - 44 - ], - "body": [ - { - "type": "ClassDeclaration", + 63 + ], + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "A" + }, + "superClass": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ], + "name": "B" + }, + "body": { + "type": "ClassBody", + "start": 18, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 18, + 63 + ], + "body": [ + { + "type": "MethodDefinition", + "start": 24, + "end": 61, "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 24, + 61 + ], + "kind": "constructor", + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "start": 24, + "end": 35, + "loc": { "start": { - "line": 1, - "column": 0 + "line": 2, + "column": 4 }, "end": { - "line": 5, - "column": 1 + "line": 2, + "column": 15 } + }, + "range": [ + 24, + 35 + ], + "name": "constructor" }, - "range": [ - 0, - 43 - ], - "id": { - "type": "Identifier", - "loc": { - "start": { - "line": 1, - "column": 6 - }, - "end": { - "line": 1, - "column": 7 - } + "value": { + "type": "FunctionExpression", + "start": 35, + "end": 61, + "loc": { + "start": { + "line": 2, + "column": 15 }, - "range": [ - 6, - 7 - ], - "name": "A" - }, - "superClass": null, - "body": { - "type": "ClassBody", + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 35, + 61 + ], + "id": null, + "expression": false, + "generator": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 37, + "end": 61, "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 5, - "column": 1 - } + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 4, + "column": 5 + } }, "range": [ - 8, - 43 + 37, + 61 ], "body": [ - { - "type": "MethodDefinition", + { + "type": "ExpressionStatement", + "start": 47, + "end": 55, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "range": [ + 47, + 55 + ], + "expression": { + "type": "CallExpression", + "start": 47, + "end": 54, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 47, + 54 + ], + "callee": { + "type": "Super", + "start": 47, + "end": 52, "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 4, - "column": 5 - } + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 13 + } }, "range": [ - 14, - 41 - ], - "computed": false, - "key": { - "type": "Identifier", - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 5 - } - }, - "range": [ - 14, - 15 - ], - "name": "a" - }, - "static": false, - "kind": "method", - "value": { - "type": "FunctionExpression", - "loc": { - "start": { - "line": 2, - "column": 5 - }, - "end": { - "line": 4, - "column": 5 - } - }, - "range": [ - 15, - 41 - ], - "id": null, - "generator": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "loc": { - "start": { - "line": 2, - "column": 7 - }, - "end": { - "line": 4, - "column": 5 - } - }, - "range": [ - 17, - 41 - ], - "body": [ - { - "type": "ExpressionStatement", - "loc": { - "start": { - "line": 3, - "column": 8 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "range": [ - 27, - 35 - ], - "expression": { - "type": "CallExpression", - "loc": { - "start": { - "line": 3, - "column": 8 - }, - "end": { - "line": 3, - "column": 15 - } - }, - "range": [ - 27, - 34 - ], - "callee": { - "type": "Super", - "loc": { - "start": { - "line": 3, - "column": 8 - }, - "end": { - "line": 3, - "column": 13 - } - }, - "range": [ - 27, - 32 - ] - }, - "arguments": [] - } - } - ] - } - } + 47, + 52 + ] + }, + "arguments": [] } + } ] + } } + } + ] + } + }, + { + "type": "EmptyStatement", + "start": 63, + "end": 64, + "loc": { + "start": { + "line": 5, + "column": 1 }, - { - "type": "EmptyStatement", - "loc": { - "start": { - "line": 5, - "column": 1 - }, - "end": { - "line": 5, - "column": 2 - } - }, - "range": [ - 43, - 44 - ] + "end": { + "line": 5, + "column": 2 } - ], - "sourceType": "script", - "tokens": [ - { - "type": "Keyword", - "value": "class", - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 5 - } - }, - "range": [ - 0, - 5 - ] + }, + "range": [ + 63, + 64 + ] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 }, - { - "type": "Identifier", - "value": "A", - "loc": { - "start": { - "line": 1, - "column": 6 - }, - "end": { - "line": 1, - "column": 7 - } - }, - "range": [ - 6, - 7 - ] + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "A", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 }, - { - "type": "Punctuator", - "value": "{", - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 9 - } - }, - "range": [ - 8, - 9 - ] + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ] + }, + { + "type": "Keyword", + "value": "extends", + "start": 8, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 8 }, - { - "type": "Identifier", - "value": "a", - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 5 - } - }, - "range": [ - 14, - 15 - ] + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 8, + 15 + ] + }, + { + "type": "Identifier", + "value": "B", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 }, - { - "type": "Punctuator", - "value": "(", - "loc": { - "start": { - "line": 2, - "column": 5 - }, - "end": { - "line": 2, - "column": 6 - } - }, - "range": [ - 15, - 16 - ] + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ] + }, + { + "type": "Punctuator", + "value": "{", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 18 }, - { - "type": "Punctuator", - "value": ")", - "loc": { - "start": { - "line": 2, - "column": 6 - }, - "end": { - "line": 2, - "column": 7 - } - }, - "range": [ - 16, - 17 - ] + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Identifier", + "value": "constructor", + "start": 24, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 4 }, - { - "type": "Punctuator", - "value": "{", - "loc": { - "start": { - "line": 2, - "column": 7 - }, - "end": { - "line": 2, - "column": 8 - } - }, - "range": [ - 17, - 18 - ] + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 24, + 35 + ] + }, + { + "type": "Punctuator", + "value": "(", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 15 }, - { - "type": "Keyword", - "value": "super", - "loc": { - "start": { - "line": 3, - "column": 8 - }, - "end": { - "line": 3, - "column": 13 - } - }, - "range": [ - 27, - 32 - ] + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 35, + 36 + ] + }, + { + "type": "Punctuator", + "value": ")", + "start": 36, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 16 }, - { - "type": "Punctuator", - "value": "(", - "loc": { - "start": { - "line": 3, - "column": 13 - }, - "end": { - "line": 3, - "column": 14 - } - }, - "range": [ - 32, - 33 - ] + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 36, + 37 + ] + }, + { + "type": "Punctuator", + "value": "{", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 17 }, - { - "type": "Punctuator", - "value": ")", - "loc": { - "start": { - "line": 3, - "column": 14 - }, - "end": { - "line": 3, - "column": 15 - } - }, - "range": [ - 33, - 34 - ] + "end": { + "line": 2, + "column": 18 + } + }, + "range": [ + 37, + 38 + ] + }, + { + "type": "Keyword", + "value": "super", + "start": 47, + "end": 52, + "loc": { + "start": { + "line": 3, + "column": 8 }, - { - "type": "Punctuator", - "value": ";", - "loc": { - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "range": [ - 34, - 35 - ] + "end": { + "line": 3, + "column": 13 + } + }, + "range": [ + 47, + 52 + ] + }, + { + "type": "Punctuator", + "value": "(", + "start": 52, + "end": 53, + "loc": { + "start": { + "line": 3, + "column": 13 }, - { - "type": "Punctuator", - "value": "}", - "loc": { - "start": { - "line": 4, - "column": 4 - }, - "end": { - "line": 4, - "column": 5 - } - }, - "range": [ - 40, - 41 - ] + "end": { + "line": 3, + "column": 14 + } + }, + "range": [ + 52, + 53 + ] + }, + { + "type": "Punctuator", + "value": ")", + "start": 53, + "end": 54, + "loc": { + "start": { + "line": 3, + "column": 14 }, - { - "type": "Punctuator", - "value": "}", - "loc": { - "start": { - "line": 5, - "column": 0 - }, - "end": { - "line": 5, - "column": 1 - } - }, - "range": [ - 42, - 43 - ] + "end": { + "line": 3, + "column": 15 + } + }, + "range": [ + 53, + 54 + ] + }, + { + "type": "Punctuator", + "value": ";", + "start": 54, + "end": 55, + "loc": { + "start": { + "line": 3, + "column": 15 }, - { - "type": "Punctuator", - "value": ";", - "loc": { - "start": { - "line": 5, - "column": 1 - }, - "end": { - "line": 5, - "column": 2 - } - }, - "range": [ - 43, - 44 - ] + "end": { + "line": 3, + "column": 16 + } + }, + "range": [ + 54, + 55 + ] + }, + { + "type": "Punctuator", + "value": "}", + "start": 60, + "end": 61, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 60, + 61 + ] + }, + { + "type": "Punctuator", + "value": "}", + "start": 62, + "end": 63, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 62, + 63 + ] + }, + { + "type": "Punctuator", + "value": ";", + "start": 63, + "end": 64, + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 2 } - ] + }, + "range": [ + 63, + 64 + ] + } + ] }; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/6/classes/class-one-method-super.src.js b/tests/fixtures/ecma-version/6/classes/class-one-method-super.src.js index 304405d3..e0867243 100644 --- a/tests/fixtures/ecma-version/6/classes/class-one-method-super.src.js +++ b/tests/fixtures/ecma-version/6/classes/class-one-method-super.src.js @@ -1,5 +1,5 @@ -class A { - a(){ +class A extends B { + constructor(){ super(); } };