Optimize spread to not generate x.slice() when x is an array literal

This commit is contained in:
Anders Hejlsberg 2015-05-12 16:53:53 -07:00 committed by Mohamed Hegazy
parent a4294a6864
commit de8b2fabb9

View File

@ -1383,7 +1383,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
e = (<SpreadElementExpression>e).expression;
emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e));
pos++;
if (pos === length && group === 0 && alwaysCopy) {
if (pos === length && group === 0 && alwaysCopy && e.kind !== SyntaxKind.ArrayLiteralExpression) {
write(".slice()");
}
}