diff --git a/packages/babel-helper-wrap-function/src/index.js b/packages/babel-helper-wrap-function/src/index.js index d36e9d267700..e1ff0d37ac81 100644 --- a/packages/babel-helper-wrap-function/src/index.js +++ b/packages/babel-helper-wrap-function/src/index.js @@ -124,7 +124,7 @@ function plainFunction(path: NodePath, callId: Object) { } export default function wrapFunction(path: NodePath, callId: Object) { - if (path.isClassMethod() || path.isObjectMethod()) { + if (path.isMethod()) { classOrObjectMethod(path, callId); } else { plainFunction(path, callId); diff --git a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/async-generators/class-private-method/input.js b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/async-generators/class-private-method/input.js new file mode 100644 index 000000000000..667708223ade --- /dev/null +++ b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/async-generators/class-private-method/input.js @@ -0,0 +1,8 @@ +class C { + async * #g() { + this; + await 1; + yield 2; + return 3; + } +} diff --git a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/async-generators/class-private-method/options.json b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/async-generators/class-private-method/options.json new file mode 100644 index 000000000000..b1d145063af9 --- /dev/null +++ b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/async-generators/class-private-method/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["external-helpers", "proposal-private-methods", "proposal-async-generator-functions"] +} diff --git a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/async-generators/class-private-method/output.js b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/async-generators/class-private-method/output.js new file mode 100644 index 000000000000..e7d3cfbe5627 --- /dev/null +++ b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/async-generators/class-private-method/output.js @@ -0,0 +1,19 @@ +var _g = new WeakSet(); + +class C { + constructor() { + _g.add(this); + } + +} + +var _g2 = function _g2() { + var _this = this; + + return babelHelpers.wrapAsyncGenerator(function* () { + _this; + yield babelHelpers.awaitAsyncGenerator(1); + yield 2; + return 3; + })(); +};