fix super spread in loose mode

This commit is contained in:
Sebastian McKenzie 2015-06-21 00:01:19 +01:00
parent 83bcaba1a5
commit 85308a1e8c
2 changed files with 8 additions and 2 deletions

View File

@ -169,7 +169,13 @@ export default class ReplaceSupers {
if (methodName.name === "constructor") {
// constructor() { super(); }
return t.memberExpression(superRef, t.identifier("call"));
if (parent.arguments.length === 2 && t.isSpreadElement(parent.arguments[1]) && t.isIdentifier(parent.arguments[1].argument, { name: "arguments" })) {
// special case single arguments spread
parent.arguments[1] = parent.arguments[1].argument;
return t.memberExpression(superRef, t.identifier("apply"));
} else {
return t.memberExpression(superRef, t.identifier("call"));
}
} else {
id = superRef;

View File

@ -1,7 +1,7 @@
import * as t from "../../../types";
function getSpreadLiteral(spread, scope) {
if (scope.hub.file.isLoose("es6.spread")) {
if (scope.hub.file.isLoose("es6.spread") && !t.isIdentifier(spread.argument, { name: "arguments" })) {
return spread.argument;
} else {
return scope.toArray(spread.argument, true);