Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

[7.0] Remove classConstructorCall plugin #291

Merged
merged 1 commit into from Jan 16, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 3 additions & 17 deletions src/parser/statement.js
Expand Up @@ -636,7 +636,6 @@ pp.parseClassBody = function (node) {
const oldStrict = this.state.strict;
this.state.strict = true;

let hadConstructorCall = false;
let hadConstructor = false;
let decorators = [];
const classBody = this.startNode();
Expand All @@ -663,7 +662,6 @@ pp.parseClassBody = function (node) {
decorators = [];
}

let isConstructorCall = false;
const isMaybeStatic = this.match(tt.name) && this.state.value === "static";
let isGenerator = this.eat(tt.star);
let isGetSet = false;
Expand All @@ -682,11 +680,6 @@ pp.parseClassBody = function (node) {
classBody.body.push(this.parseClassProperty(method));
continue;
}

if (method.key.type === "Identifier" && !method.computed && this.hasPlugin("classConstructorCall") && method.key.name === "call" && this.match(tt.name) && this.state.value === "constructor") {
isConstructorCall = true;
this.parsePropertyName(method);
}
}

const isAsyncMethod = !this.match(tt.parenL) && !method.computed && method.key.type === "Identifier" && method.key.name === "async";
Expand All @@ -710,7 +703,7 @@ pp.parseClassBody = function (node) {
}

// disallow invalid constructors
const isConstructor = !isConstructorCall && !method.static && (
const isConstructor = !method.static && (
(key.type === "Identifier" && key.name === "constructor") ||
(key.type === "StringLiteral" && key.value === "constructor")
);
Expand All @@ -733,15 +726,8 @@ pp.parseClassBody = function (node) {
}
}

// convert constructor to a constructor call
if (isConstructorCall) {
if (hadConstructorCall) this.raise(method.start, "Duplicate constructor call in the same class");
method.kind = "constructorCall";
hadConstructorCall = true;
}

// disallow decorators on class constructors
if ((method.kind === "constructor" || method.kind === "constructorCall") && method.decorators) {
// disallow decorators on class constructors
if (method.kind === "constructor" && method.decorators) {
this.raise(method.start, "You can't attach decorators to a class constructor");
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

186 changes: 0 additions & 186 deletions test/fixtures/experimental/class-constructor-call/plain/expected.json

This file was deleted.