special case single super method call with spread, fixes #227

This commit is contained in:
Sebastian McKenzie
2015-01-13 01:09:10 +11:00
parent 123186003c
commit 831b420df3
2 changed files with 23 additions and 15 deletions

View File

@@ -289,10 +289,18 @@ Class.prototype.replaceInstanceSuperReferences = function (methodNode) {
var superProperty = self.superProperty(property, methodNode.static, computed, thisReference);
if (args) {
return t.callExpression(
t.memberExpression(superProperty, t.identifier("call"), false),
[thisReference].concat(args)
);
if (args.length === 1 && t.isSpreadElement(args[0])) {
// super(...arguments);
return t.callExpression(
t.memberExpression(superProperty, t.identifier("apply"), false),
[thisReference, args[0].argument]
);
} else {
return t.callExpression(
t.memberExpression(superProperty, t.identifier("call"), false),
[thisReference].concat(args)
);
}
} else {
return superProperty;
}