diff --git a/src/babel/transformation/transformers/es6/arrow-functions.js b/src/babel/transformation/transformers/es6/arrow-functions.js index 47d53a25fa..33a4c10854 100644 --- a/src/babel/transformation/transformers/es6/arrow-functions.js +++ b/src/babel/transformation/transformers/es6/arrow-functions.js @@ -6,7 +6,8 @@ export function ArrowFunctionExpression(node) { t.ensureBlock(node); node.expression = false; - node.type = "ShadowFunctionExpression"; + node.type = "FunctionExpression"; + node.shadow = true; return node; } diff --git a/src/babel/transformation/transformers/es6/block-scoping.js b/src/babel/transformation/transformers/es6/block-scoping.js index 93ff7783bb..7223dc5bd6 100644 --- a/src/babel/transformation/transformers/es6/block-scoping.js +++ b/src/babel/transformation/transformers/es6/block-scoping.js @@ -354,7 +354,8 @@ class BlockScoping { var params = values(outsideRefs); // build the closure that we're going to wrap the block with - var fn = t.shadowFunctionExpression(null, params, t.blockStatement(block.body)); + var fn = t.functionExpression(null, params, t.blockStatement(block.body)); + fn.shadow = true; // replace the current block body with the one we're going to build block.body = this.body; diff --git a/src/babel/transformation/transformers/es6/parameters.default.js b/src/babel/transformation/transformers/es6/parameters.default.js index 7941967784..2928a4aebb 100644 --- a/src/babel/transformation/transformers/es6/parameters.default.js +++ b/src/babel/transformation/transformers/es6/parameters.default.js @@ -91,7 +91,8 @@ exports.Function = function (node, parent, scope, file) { node.params = node.params.slice(0, lastNonDefaultParam); if (state.iife) { - var container = t.shadowFunctionExpression(null, [], node.body, node.generator); + var container = t.functionExpression(null, [], node.body, node.generator); + container.shadow = true; body.push(t.returnStatement(t.callExpression(container, []))); diff --git a/src/babel/transformation/transformers/es7/comprehensions.js b/src/babel/transformation/transformers/es7/comprehensions.js index 848a32ffe7..cddcc16516 100644 --- a/src/babel/transformation/transformers/es7/comprehensions.js +++ b/src/babel/transformation/transformers/es7/comprehensions.js @@ -16,7 +16,8 @@ export function ComprehensionExpression(node, parent, scope, file) { function generator(node) { var body = []; - var container = t.shadowFunctionExpression(null, [], t.blockStatement(body), true); + var container = t.functionExpression(null, [], t.blockStatement(body), true); + container.shadow = true; body.push(buildComprehension(node, function () { return t.expressionStatement(t.yieldExpression(node.body)); @@ -31,7 +32,7 @@ function array(node, parent, scope, file) { var container = util.template("array-comprehension-container", { KEY: uid }); - container.callee.type = "ShadowFunctionExpression"; + container.callee.shadow = true; var block = container.callee.body; var body = block.body; diff --git a/src/babel/transformation/transformers/internal/alias-functions.js b/src/babel/transformation/transformers/internal/alias-functions.js index e92ece5a7f..cf5f4bf59f 100644 --- a/src/babel/transformation/transformers/internal/alias-functions.js +++ b/src/babel/transformation/transformers/internal/alias-functions.js @@ -2,7 +2,7 @@ import * as t from "../../../types"; var functionChildrenVisitor = { enter(node, parent, scope, state) { - if (this.isFunction()) { + if (this.isFunction() && !node.shadow) { return this.skip(); } @@ -24,17 +24,19 @@ var functionChildrenVisitor = { var functionVisitor = { enter(node, parent, scope, state) { - if (this.isFunction()) { - // stop traversal of this node as it'll be hit again by this transformer - return this.skip(); - } else if (!this.isShadowFunctionExpression()) { - return; + if (!node.shadow) { + if (this.isFunction()) { + // stop traversal of this node as it'll be hit again by this transformer + return this.skip(); + } else { + return; + } } // traverse all child nodes of this function and find `arguments` and `this` this.traverse(functionChildrenVisitor, state); - node.type = "FunctionExpression"; + node.shadow = false; return this.skip(); } diff --git a/src/babel/types/alias-keys.json b/src/babel/types/alias-keys.json index 784e2eb78f..8007c4ccdb 100644 --- a/src/babel/types/alias-keys.json +++ b/src/babel/types/alias-keys.json @@ -53,7 +53,6 @@ "ArrayExpression": ["Expression"], "AssignmentExpression": ["Expression"], "AwaitExpression": ["Expression"], - "ShadowFunctionExpression": ["Expression"], "CallExpression": ["Expression"], "ComprehensionExpression": ["Expression", "Scopable"], "ConditionalExpression": ["Expression"], diff --git a/src/babel/types/builder-keys.json b/src/babel/types/builder-keys.json index b273d89207..65fee94c49 100644 --- a/src/babel/types/builder-keys.json +++ b/src/babel/types/builder-keys.json @@ -45,13 +45,6 @@ "tokens": null }, - "ShadowFunctionExpression": { - "id": null, - "params": null, - "body": null, - "generator": false - }, - "FunctionExpression": { "id": null, "params": null, diff --git a/src/babel/types/visitor-keys.json b/src/babel/types/visitor-keys.json index 83bd7beeed..1ff8df5b8b 100644 --- a/src/babel/types/visitor-keys.json +++ b/src/babel/types/visitor-keys.json @@ -32,7 +32,6 @@ "ForStatement": ["init", "test", "update", "body"], "FunctionDeclaration": ["id", "params", "defaults", "rest", "body", "returnType", "typeParameters"], "FunctionExpression": ["id", "params", "defaults", "rest", "body", "returnType", "typeParameters"], - "ShadowFunctionExpression": ["id", "params", "defaults", "rest", "body", "returnType", "typeParameters"], "Identifier": ["typeAnnotation"], "IfStatement": ["test", "consequent", "alternate"], "ImportDefaultSpecifier": ["local"],