Merge pull request #2861 from hzoo/i-2838

helper-remap-async-to-generator: account for ObjectMethod - fixes #2838
This commit is contained in:
Sebastian McKenzie 2015-11-06 19:40:30 -05:00
commit 9a1cf40296
3 changed files with 17 additions and 3 deletions

View File

@ -0,0 +1,6 @@
let obj = {
a: 123,
async foo(bar) {
return await baz(bar);
}
}

View File

@ -0,0 +1,8 @@
let obj = {
a: 123,
foo(bar) {
return babelHelpers.asyncToGenerator(function* () {
return yield baz(bar);
})();
}
};

View File

@ -24,7 +24,7 @@ let awaitVisitor = {
}
};
function classMethod(path: NodePath, callId: Object) {
function classOrObjectMethod(path: NodePath, callId: Object) {
let node = path.node;
let body = node.body;
@ -99,8 +99,8 @@ export default function (path: NodePath, callId: Object) {
path.traverse(awaitVisitor);
if (path.isClassMethod()) {
return classMethod(path, callId);
if (path.isClassMethod() || path.isObjectMethod()) {
return classOrObjectMethod(path, callId);
} else {
return plainFunction(path, callId);
}