Skip to content

Commit

Permalink
Fix bug in zero-args calls to the impl
Browse files Browse the repository at this point in the history
This was introduced in 4dd82b0.
  • Loading branch information
domenic committed Apr 29, 2017
1 parent 42d1968 commit 5013091
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/constructs/operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,23 @@ Operation.prototype.generate = function () {
const callOn = this.idl.static ? "Impl" : "this[impl]";

const parameterConversions = Parameters.generateOverloadConversions(overloads, this.obj.opts.customTypes);
const argsSpread = parameterConversions.hasArgs ? "...args" : "";
Object.assign(requires, parameterConversions.requires);
str += parameterConversions.body;
if (!this.idl.stringifier && overloads.every((overload) => conversions[overload.operation.idlType.idlType])) {
str += `
return ${callOn}.${name}.apply(${callOn}, args);
return ${callOn}.${name}(${argsSpread});
};\n`;
} else {
str += `
return utils.tryWrapperForImpl(${callOn}.${name}.apply(${callOn}, args));
return utils.tryWrapperForImpl(${callOn}.${name}(${argsSpread}));
};\n`;
}
if (this.idl.stringifier && name !== "toString") {
str += `\n${this.name}.prototype.toString(${minConstructor.nameList.join(", ")}) {`;
str += parameterConversions.body;
str += `
return ${callOn}.${name}.apply(${callOn}, args);
return ${callOn}.${name}.apply(${argsSpread});
};\n`;
}

Expand Down
3 changes: 2 additions & 1 deletion lib/parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ module.exports.generateOverloadConversions = function (overloads, customTypes) {
}
return {
requires,
body: str
body: str,
hasArgs: !isAlwaysZeroArgs
};
};

0 comments on commit 5013091

Please sign in to comment.